Small fixes & refactoring