major improvements and tests