clean up the code and moved magma to bin folder