Fix for shorting with non-XTS base
Major refactor of market engine

Fix several bugs and general code cleanup