better logging, fixed some indexing bugs related to arrays