More work on control. Changed some function to pointers.