Refactor

Needs testing, bips_server may not work