Added clear undef option
fixed clear_undef test, code refactoring
build-in doc update