Cleaned up code.

1. Moved from multiplex to mult
2. Moved functions inside a global function to avoid passing settings as parameters
3. Added some comments and changed some binding names.