code optimizations
bug fixes