Performance enhancement and bug fixes