updated type casting, array arithmetics
implemented different codes for VS2012 vs VS2013(C+11)