Improved input reading, closes #3