Fixed bugs in system