Applied some bug corrections