Bug with begins and ends fixed
Some renames
optimization