Fix indentation, improve readability, add comments