FIX: Various bug fixes.