Incorperates more changes from #373 in order to fix issue #296