Did  some bug fixes