Database, php, and some other files are updated.

Database, php, some acitivties and everything is restructured. more
comments are added. Version: Just before testing with the real switches.