use short ints when applicable, and define functions as const