Fixing issue 113 through the merging of #136 and #33. Thanks Nomeasmo