Refactor and documentation for frontend