WIP on issue #4 . Not working at all right now, see @TODOs