Fixed #72 with a bit of re-ordering