Code cleanup

Attempted at making code more consistent and readable