Code style and related minor performance optimizations

Closes gh-113.