several bugs corrected