Many bugs corrected