Fixed coding errors

Applied fixes to the code that are documented in a forum post.