added sig extraction, and fixed some code issues