fix deprecation warnings, add annotations, cleanup