Numerous small additions and bug fixes