Refactor backend after code review

So much files changed.