Fixed backend bugs. Front end needs to be fixed