Fixes various bugs and adds diagnostic gems