Fixed major issues in code.