Correct coding styles
Correct coding styles more
Split long function