Code cleanup

Cleanup and DRY