minor code refactoring, also begin work to support ARM