Fixed bugs, added minor functionality