Several Bugs fixed