Fixed problem with input keys not working. Apparently I don't know the order of arguments in memcpy very well...