Fixing bugs and improving sim and bs implementation