Stylistic changes

Made usage of {} consistent across all functions, added some comments, fixed typos