Fix for array problems and remove magic number.