Multiple bugs corrected