Refactoring done, fine tuning left.