Some optimizations

Ref #28
Fix array
Merge pull request #29 from Xety/optimizations

Some optimizations