Fixed signed signals bugs. Cleaned up main code.