Refactorings

@lucasvanlierop could you review this?