Performance fixes

Close #12 and #13