Refractor more code