Added refractring and cleanup + javadoc