Add sqrt, fix stack calculation