Added a few bits and bobs to make this work