Added some bug fixes