Some bugs corrected