Add a get_extension() convenience function.
Various cleanups and backborts.