Fixes #31 and Fixes afew issues for #17

Closed #31