dirty check arrays much faster
minor cleanup and bug fix