[Refactor] Keep architecture dependent code together and add comments.