Fixed empty line adding. Fixed encoding problems. Commenting. Refactoring.