Some refactoring. Trying to group the methods in a logical way to increase codereadability.