Some small bugs fixed