Added pause key

plus some minor optimizations