final correction of design and fix bugs.