misc py improvements