added instucting and small optimizations (firefox is performing strangely now)