added references, bug fixes