Implemented simple linked-list to keep track of module states.

These states need to be released when the context is released, so the
module_state structure is now a linked-list.