initial import
optimizations and more unit tests