Removed warnings and fixed bugs