Improve autocomplete

Hi!

![akltl](https://cloud.githubusercontent.com/assets/158987/3691766/e22406a4-1355-11e4-97c2-105afcf7af39.jpg)

So this branch just tidies up the code a little bit it doesn't actually update any new features, but keeps in nice and tidy. I suppose technically it supports pressing up/down in the chat box a bit better.

I would maybe see if this breaks anything before merging?