Fixes bugs and #1