Improve code

@Dynious : Please don't pull this, many commits to go. This will be a pull request going through (probably) every file. Although not all files may be changed.