Fix some ugly hacks