Add last activity support
Several bug fixes