Misc cleanup- memory and subscript errors are abundant