Implements issue #44 + some semantic cleanup