Buffer overflow issues fixed