Several improvements and refactorings Iteration 5