Cleanup and refactorings
I dislike code like this