changed order of statements to allow for caching and faster compilation
fixed scrolling of history window, now automatically scrolls to the last entry