Changed the Array structure to a more easy one ;-)

Optimize and clean up code

fixed bugs