cleaned up code, added comments, sanitization and readied for VIP review