Simplified Code, fixed all known bugs