Code improvements

Improved some classes with better style, used newer syntax features and simplified some things. Details in the commit messages.