Several improvements and refactorings Iteration 6