Improved readbility, style, and some code