cleanup and add typehints