Fix some compile errors.
Fix some compile errors.
Some refactoring.
Merge remote-tracking branch 'Selat/circuit'