Code cleanup, remote keyboard fixes