more refactorings; some bugs fixed; more found