API and widgets loop optimization
http://jsperf.com/for-vs-whilepop/5

fixed bugs and other little improvements