add back in the changes made for flat multi-module support (note: some parts needs to be reviewed and updated as necessary before merging to trunk)