code cleanup & refactorings