Fixed bug in stem function.