Updates from previous patch set: * moved raise to a post-switch action * prevented mapping from occurring before the first context switch * adjusted the api according to suggestions