Various changes to try and improve performance [issue #10]