more typed arrays and refactoring