Potential bugs fixed