Fixed multiple bugs in frontend and backend