Fixing issue #18

Rather hackish fix. Probably needs a revisit in the future.