Simplify JRM: Remove unused imports; re-write messy funcs.

Change-Id: I3e7396e73ffb7b7c1bff9469ac5beb6677cc072f
Merge "Simplify JRM: Remove unused imports; re-write messy funcs."