Made all the necessary bug fixes