moving some core functionality into lua