First try at solving #5 (but needs more testing)
Unbroke a60c89c609e087de0a42a6f45357693078709207 further
Small fixes. Current tests are passing now, but more testing is required.