Fixed bugs, now works as it did before