Updated code and fixed bugs. Tested on tablet. The system works.