Cleanups + small refactoring