Some bugs corrected.