Fixes #2 and add solution to #3