Beta version; Various bug-fixes and reformatted code