Fix a few reported issues. Closes #2, #3, #4, #5