Added getfields functionality with other minor changes