Cleanup and reduce duplicated code
Add linting