Simplification and bug fixes,