performance improvements, fix the defaults problem
add tests