Refactor application code