Further refactoring/code improving