generic: cleanup code
generic: comment all the code and provide some examples