Cleanup codebase

Hi

I know this pull request is huge, but it's only refactoring and cleaning a little bit the code, reformatting it and such.
I have others pull requests that awaits the approval of this one, and I have much more stuff that I want to do.

Thanks a lot for this great app !