All over refactoring

Added comments, changed structure and actually managed to remove a LOT
of code which was superfluous.