Fix lint errors and cleanup code