various bug fix and extensions.