improve readability and code style by indenting lines, cleaning up trailing whitespaces + some slight refactorings