Some refactoring

I moved the implementations in own files to make it easier to change. Maybe it'll help you too