Initial commit with ported and broken out functionality.