Fixed various bugs, class fixed