Code refactoring; some fixes