Finally not crashing... memory mgmt is questionable though