Frontend cleanup
Code deduplication