Bug fixes and proper cond-expand