refactor

Some more refactors, to make it cleaner.