fixed arrays, doubles, refactoring