Removed unsed vars and moved die() to share