fixes #1187, refactor log det and type bug in array alloc