Fix for issue #665 and enhancement for issue #666

Missing closing brace at end of last function.