Manually added changes from PR #13 (I'm really bad with git...)