Fixed a few edge cases and refactored get_field()