Tidied up lambda functions for my mode hooks.