Implemented #17

Trying to implement #17. Needs testing.