Did some bug fixes