fixed some small bugs introduced in code refactoring