Fix bugs found during testing. Use a macro for sign extension and fix the fixmes about it.