Added inline editing of metadata and cleaned up code