Handle function hoisting (approximately)

[closes #1]