Module and states code refactor

Change-Id: Ia1c468d0b55603b6274ca0d275b2720602e5319e
14 files changed