Removed debug and fixed bugs