Proper definitions and cleaner context manager