Performance optimisations by using the inspect module more sparingly.