Fixed code style and commenting at @bencorlett 's advice