Correct use of perl stack macros

Further to pull #49 this is the result of an audit of the use of perl
stack macros. There were several cases where PUTBACK was being called
where the stack pointer could be out-of-date.

Also some misc. cleanup where the macros were used needlessly.