Fix issue #1 and other minor changes (thanks @jayschwa)