Sources merger

An attempt to merge previous changes. Still decent functionality.