various improvements. bug fixes