Code optimization, linting, cleanup