Merged changes from CDI branch
Fixed merge (unit tests now pass)