Various bug fixes, improvements and new features