Fixed small logical errors, added character count