fixed compiler warnings; minor refactoring