Added control code and constants

This code hasn't been tested yet