Fixed bugs; works fine now.