Various changes:
Various changes:

* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().

--- a/src/in_2sf/XSFConfig_2SF.cpp
+++ b/src/in_2sf/XSFConfig_2SF.cpp
@@ -6,11 +6,16 @@
  */
 
 #include <bitset>
-#include "XSFPlayer.h"
+#include <sstream>
+#include <string>
+#include <cstddef>
+#include "windowsh_wrapper.h"
 #include "XSFConfig.h"
 #include "convert.h"
 #include "desmume/NDSSystem.h"
 #include "desmume/version.h"
+
+class XSFPlayer;
 
 enum
 {
@@ -71,11 +76,11 @@
 
 void XSFConfig_2SF::GenerateSpecificDialogs()
 {
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idInterpolation).IsDropDownList().
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idInterpolation).IsDropDownList().
 		WithTabStop());
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder().
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder().
 		WithVerticalScrollbar().WithMultipleSelect().WithTabStop());
 }
 
@@ -91,7 +96,7 @@
 			SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Sharp Interpolation"));
 			SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, this->interpolation, 0);
 			// Mutes
-			for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
+			for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
 			{
 				SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((L"SPU " + std::to_wstring(x + 1)).c_str()));
 				SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, this->mutes[x], x);
@@ -108,14 +113,14 @@
 {
 	SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, XSFConfig_2SF::initInterpolation, 0);
 	auto tmpMutes = std::bitset<16>(XSFConfig_2SF::initMutes);
-	for (size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x)
+	for (std::size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x)
 		SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, tmpMutes[x], x);
 }
 
 void XSFConfig_2SF::SaveSpecificConfigDialog(HWND hwndDlg)
 {
 	this->interpolation = static_cast<unsigned>(SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_GETCURSEL, 0, 0));
-	for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
+	for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
 		this->mutes[x] = !!SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_GETSEL, x, 0);
 }
 
@@ -124,7 +129,7 @@
 	if (!preLoad)
 	{
 		CommonSettings.spuInterpolationMode = static_cast<SPUInterpolationMode>(this->interpolation);
-		for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
+		for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
 			CommonSettings.spu_muteChannels[x] = this->mutes[x];
 	}
 }

--- a/src/in_2sf/XSFPlayer_2SF.cpp
+++ b/src/in_2sf/XSFPlayer_2SF.cpp
@@ -10,19 +10,22 @@
  * http://desmume.org/
  */
 
+#include <algorithm>
 #include <filesystem>
 #include <memory>
+#include <string>
+#include <vector>
+#include <cstdint>
 #include <zlib.h>
-#include "convert.h"
+#include "XSFCommon.h"
 #include "XSFPlayer.h"
-#include "XSFCommon.h"
 #include "desmume/NDSSystem.h"
 
 class XSFPlayer_2SF : public XSFPlayer
 {
-	std::vector<uint8_t> rom;
-
-	void Map2SFSection(const std::vector<uint8_t> &section);
+	std::vector<std::uint8_t> rom;
+
+	void Map2SFSection(const std::vector<std::uint8_t> &section);
 	bool Map2SF(XSFFile *xSFToLoad);
 	bool RecursiveLoad2SF(XSFFile *xSFToLoad, int level);
 	bool Load2SF(XSFFile *xSFToLoad);
@@ -33,7 +36,7 @@
 #endif
 	~XSFPlayer_2SF() { this->Terminate(); }
 	bool Load();
-	void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples);
+	void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples);
 	void Terminate();
 };
 
@@ -56,17 +59,17 @@
 
 static struct
 {
-	std::vector<uint8_t> buf;
+	std::vector<std::uint8_t> buf;
 	unsigned filled, used;
-	uint32_t bufferbytes, cycles;
+	std::uint32_t bufferbytes, cycles;
 	int xfs_load, sync_type;
-} sndifwork = { std::vector<uint8_t>(), 0, 0, 0, 0, 0, 0 };
+} sndifwork = { std::vector<std::uint8_t>(), 0, 0, 0, 0, 0, 0 };
 
 static void SNDIFDeInit() { }
 
 static int SNDIFInit(int buffersize)
 {
-	uint32_t bufferbytes = buffersize * sizeof(int16_t);
+	std::uint32_t bufferbytes = buffersize * sizeof(std::int16_t);
 	SNDIFDeInit();
 	sndifwork.buf.resize(bufferbytes + 3);
 	sndifwork.bufferbytes = bufferbytes;
@@ -79,17 +82,17 @@
 static void SNDIFUnMuteAudio() { }
 static void SNDIFSetVolume(int) { }
 
-static uint32_t SNDIFGetAudioSpace()
+static std::uint32_t SNDIFGetAudioSpace()
 {
 	return sndifwork.bufferbytes >> 2; // bytes to samples
 }
 
-static void SNDIFUpdateAudio(int16_t *buffer, uint32_t num_samples)
-{
-	uint32_t num_bytes = num_samples << 2;
+static void SNDIFUpdateAudio(std::int16_t *buffer, std::uint32_t num_samples)
+{
+	std::uint32_t num_bytes = num_samples << 2;
 	if (num_bytes > sndifwork.bufferbytes)
 		num_bytes = sndifwork.bufferbytes;
-	std::copy_n(reinterpret_cast<uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]);
+	std::copy_n(reinterpret_cast<std::uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]);
 	sndifwork.filled = num_bytes;
 	sndifwork.used = 0;
 }
@@ -118,9 +121,9 @@
 	nullptr
 };
 
-void XSFPlayer_2SF::Map2SFSection(const std::vector<uint8_t> &section)
-{
-	uint32_t offset = Get32BitsLE(&section[0]), size = Get32BitsLE(&section[4]), finalSize = size + offset;
+void XSFPlayer_2SF::Map2SFSection(const std::vector<std::uint8_t> &section)
+{
+	std::uint32_t offset = Get32BitsLE(&section[0]), size = Get32BitsLE(&section[4]), finalSize = size + offset;
 	finalSize = NextHighestPowerOf2(finalSize);
 	if (this->rom.empty())
 		this->rom.resize(finalSize + 10, 0);
@@ -244,15 +247,15 @@
 	return XSFPlayer::Load();
 }
 
-void XSFPlayer_2SF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples)
+void XSFPlayer_2SF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples)
 {
 	static const double HBASE_CYCLES = 33509300.322234;
 	static const int HLINE_CYCLES = 6 * (99 + 256);
-	static const uint32_t HSAMPLES = static_cast<uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES) / HBASE_CYCLES);
+	std::uint32_t HSAMPLES = static_cast<std::uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES) / HBASE_CYCLES);
 	static const int VDIVISION = 100;
 	static const int VLINES = 263;
 	static const double VBASE_CYCLES = HBASE_CYCLES / VDIVISION;
-	static const uint32_t VSAMPLES = static_cast<uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES * VLINES) / HBASE_CYCLES);
+	std::uint32_t VSAMPLES = static_cast<std::uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES * VLINES) / HBASE_CYCLES);
 
 	if (!sndifwork.xfs_load)
 		return;
@@ -286,19 +289,19 @@
 			{
 				/* vsync */
 				sndifwork.cycles += (this->sampleRate / VDIVISION) * HLINE_CYCLES * VLINES;
-				if (sndifwork.cycles >= static_cast<uint32_t>(VBASE_CYCLES * (VSAMPLES + 1)))
-					sndifwork.cycles -= static_cast<uint32_t>(VBASE_CYCLES * (VSAMPLES + 1));
+				if (sndifwork.cycles >= static_cast<std::uint32_t>(VBASE_CYCLES * (VSAMPLES + 1)))
+					sndifwork.cycles -= static_cast<std::uint32_t>(VBASE_CYCLES * (VSAMPLES + 1));
 				else
-					sndifwork.cycles -= static_cast<uint32_t>(VBASE_CYCLES * VSAMPLES);
+					sndifwork.cycles -= static_cast<std::uint32_t>(VBASE_CYCLES * VSAMPLES);
 			}
 			else
 			{
 				/* hsync */
 				sndifwork.cycles += this->sampleRate * HLINE_CYCLES;
-				if (sndifwork.cycles >= static_cast<uint32_t>(HBASE_CYCLES * (HSAMPLES + 1)))
-					sndifwork.cycles -= static_cast<uint32_t>(HBASE_CYCLES * (HSAMPLES + 1));
+				if (sndifwork.cycles >= static_cast<std::uint32_t>(HBASE_CYCLES * (HSAMPLES + 1)))
+					sndifwork.cycles -= static_cast<std::uint32_t>(HBASE_CYCLES * (HSAMPLES + 1));
 				else
-					sndifwork.cycles -= static_cast<uint32_t>(HBASE_CYCLES * HSAMPLES);
+					sndifwork.cycles -= static_cast<std::uint32_t>(HBASE_CYCLES * HSAMPLES);
 			}
 			NDS_exec<false>();
 			SPU_Emulate_user();

--- a/src/in_gsf/XSFConfig_GSF.cpp
+++ b/src/in_gsf/XSFConfig_GSF.cpp
@@ -6,10 +6,14 @@
  */
 
 #include <bitset>
-#include "XSFPlayer.h"
+#include <sstream>
+#include <string>
+#include "windowsh_wrapper.h"
 #include "XSFConfig.h"
 #include "convert.h"
 #include "vbam/gba/Sound.h"
+
+class XSFPlayer;
 
 enum
 {
@@ -80,10 +84,10 @@
 
 void XSFConfig_GSF::GenerateSpecificDialogs()
 {
-	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Low-Pass Filtering").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop().
+	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Low-Pass Filtering").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop().
 		WithID(idLowPassFiltering));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10)).IsLeftJustified());
-	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder().
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10)).IsLeftJustified());
+	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder().
 		WithVerticalScrollbar().WithMultipleSelect().WithTabStop());
 }
 

--- a/src/in_gsf/XSFPlayer_GSF.cpp
+++ b/src/in_gsf/XSFPlayer_GSF.cpp
@@ -10,12 +10,16 @@
  * http://vba-m.com/
  */
 
+#include <algorithm>
 #include <filesystem>
 #include <memory>
+#include <string>
+#include <vector>
+#include <cstddef>
+#include <cstdint>
 #include <zlib.h>
-#include "convert.h"
+#include "XSFCommon.h"
 #include "XSFPlayer.h"
-#include "XSFCommon.h"
 #include "vbam/gba/Globals.h"
 #include "vbam/gba/Sound.h"
 #include "vbam/common/SoundDriver.h"
@@ -29,7 +33,7 @@
 #endif
 	~XSFPlayer_GSF() { this->Terminate(); }
 	bool Load();
-	void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples);
+	void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples);
 	void Terminate();
 };
 
@@ -50,13 +54,13 @@
 
 static struct
 {
-	std::vector<uint8_t> rom;
+	std::vector<std::uint8_t> rom;
 	unsigned entry;
-} loaderwork = { std::vector<uint8_t>(), 0 };
-
-int mapgsf(uint8_t *d, int l, int &s)
-{
-	if (static_cast<size_t>(l) > loaderwork.rom.size())
+} loaderwork = { std::vector<std::uint8_t>(), 0 };
+
+int mapgsf(std::uint8_t *d, int l, int &s)
+{
+	if (static_cast<std::size_t>(l) > loaderwork.rom.size())
 		l = loaderwork.rom.size();
 	if (l)
 		std::copy_n(&loaderwork.rom[0], l, d);
@@ -66,9 +70,9 @@
 
 static struct
 {
-	std::vector<uint8_t> buf;
-	uint32_t len, fil, cur;
-} buffer = { std::vector<uint8_t>(), 0, 0, 0 };
+	std::vector<std::uint8_t> buf;
+	std::uint32_t len, fil, cur;
+} buffer = { std::vector<std::uint8_t>(), 0, 0, 0 };
 
 class GSFSoundDriver : public SoundDriver
 {
@@ -81,7 +85,7 @@
 	bool init(long sampleRate)
 	{
 		freebuffer();
-		uint32_t len = (sampleRate / 10) << 2;
+		std::int32_t len = (sampleRate / 10) << 2;
 		buffer.buf.resize(len);
 		buffer.len = len;
 		return true;
@@ -99,13 +103,13 @@
 	{
 	}
 
-	void write(uint16_t *finalWave, int length)
-	{
-		if (static_cast<uint32_t>(length) > buffer.len - buffer.fil)
+	void write(std::uint16_t *finalWave, int length)
+	{
+		if (static_cast<std::uint32_t>(length) > buffer.len - buffer.fil)
 			length = buffer.len - buffer.fil;
 		if (length > 0)
 		{
-			std::copy_n(reinterpret_cast<uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]);
+			std::copy_n(reinterpret_cast<std::uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]);
 			buffer.fil += length;
 		}
 	}
@@ -120,11 +124,11 @@
 	return new GSFSoundDriver();
 }
 
-static void MapGSFSection(const std::vector<uint8_t> &section, int level)
+static void MapGSFSection(const std::vector<std::uint8_t> &section, int level)
 {
 	auto &data = loaderwork.rom;
 
-	uint32_t entry = Get32BitsLE(&section[0]), offset = Get32BitsLE(&section[4]) & 0x1FFFFFF, size = Get32BitsLE(&section[8]), finalSize = size + offset;
+	std::uint32_t entry = Get32BitsLE(&section[0]), offset = Get32BitsLE(&section[4]) & 0x1FFFFFF, size = Get32BitsLE(&section[8]), finalSize = size + offset;
 	if (level == 1)
 		loaderwork.entry = entry;
 	finalSize = NextHighestPowerOf2(finalSize);
@@ -226,7 +230,7 @@
 	return XSFPlayer::Load();
 }
 
-void XSFPlayer_GSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples)
+void XSFPlayer_GSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples)
 {
 	unsigned bytes = samples << 2;
 	while (bytes)

--- a/src/in_ncsf/SSEQPlayer/Channel.cpp
+++ b/src/in_ncsf/SSEQPlayer/Channel.cpp
@@ -10,10 +10,19 @@
  * http://desmume.org/
  */
 
-#include "XSFCommon.h"
+#include <algorithm>
+#include <vector>
+#define _USE_MATH_DEFINES
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
 #include "Channel.h"
 #include "Player.h"
+#include "SWAV.h"
+#include "Track.h"
+#include "XSFCommon.h"
 #include "common.h"
+#include "consts.h"
 
 NDSSoundRegister::NDSSoundRegister() : volumeMul(0), volumeDiv(0), panning(0), waveDuty(0), repeatMode(0), format(0), enable(false),
 	source(nullptr), timer(0), psgX(0), psgLast(0), psgLastCount(0), samplePosition(0), sampleIncrease(0), loopStart(0), length(0), totalLength(0)
@@ -26,7 +35,7 @@
 	this->enable = false;
 }
 
-void NDSSoundRegister::SetControlRegister(uint32_t reg)
+void NDSSoundRegister::SetControlRegister(std::uint32_t reg)
 {
 	this->volumeMul = reg & 0x7F;
 	this->volumeDiv = (reg >> 8) & 0x03;
@@ -54,7 +63,7 @@
 	return fEqual(x, 0.0) ? 1.0 : std::sin(x * M_PI) / (x * M_PI);
 }
 
-Channel::Channel() : chnId(-1), tempReg(), state(CS_NONE), trackId(-1), prio(0), manualSweep(false), flags(), pan(0), extAmpl(0), velocity(0), extPan(0),
+Channel::Channel() : chnId(-1), tempReg(), state(ChannelState::None), trackId(-1), prio(0), manualSweep(false), flags(), pan(0), extAmpl(0), velocity(0), extPan(0),
 	key(0), ampl(0), extTune(0), orgKey(0), modType(0), modSpeed(0), modDepth(0), modRange(0), modDelay(0), modDelayCnt(0), modCounter(0),
 	sweepLen(0), sweepCnt(0), sweepPitch(0), attackLvl(0), sustainLvl(0x7F), decayRate(0), releaseRate(0xFFFF), noteLength(-1), vol(0), ply(nullptr), reg(),
 	ringBuffer()
@@ -114,7 +123,7 @@
 	this->manualSweep = false;
 	this->sweepPitch = trk.sweepPitch;
 	this->sweepCnt = 0;
-	if (!trk.state[TS_PORTABIT])
+	if (!trk.state[ToIntegral(TrackState::PortamentoBit)])
 	{
 		this->sweepLen = 0;
 		return;
@@ -130,7 +139,7 @@
 	}
 	else
 	{
-		int sq_time = static_cast<uint32_t>(trk.portaTime) * static_cast<uint32_t>(trk.portaTime);
+		int sq_time = static_cast<std::uint32_t>(trk.portaTime) * static_cast<std::uint32_t>(trk.portaTime);
 		int abs_sp = std::abs(this->sweepPitch);
 		this->sweepLen = (abs_sp * sq_time) >> 11;
 	}
@@ -141,13 +150,13 @@
 {
 	this->noteLength = -1;
 	this->prio = 1;
-	this->state = CS_RELEASE;
+	this->state = ChannelState::Release;
 }
 
 // Original FSS Function: Chn_Kill
 void Channel::Kill()
 {
-	this->state = CS_NONE;
+	this->state = ChannelState::None;
 	this->trackId = -1;
 	this->prio = 0;
 	this->reg.ClearControlRegister();
@@ -155,18 +164,16 @@
 	this->noteLength = -1;
 }
 
-static inline int getModFlag(int type)
+static inline ChannelFlag getModFlag(int type)
 {
 	switch (type)
 	{
 		case 0:
-			return CF_UPDTMR;
-		case 1:
-			return CF_UPDVOL;
+			return ChannelFlag::UpdateTimer;
 		case 2:
-			return CF_UPDPAN;
-		default:
-			return 0;
+			return ChannelFlag::UpdatePan;
+		default: // basically 1
+			return ChannelFlag::UpdateVolume;
 	}
 }
 
@@ -185,46 +192,46 @@
 	if (trackFlags.none())
 		return;
 
-	if (trackFlags[TUF_LEN])
-	{
-		int st = this->state;
-		if (st > CS_START)
-		{
-			if (st < CS_RELEASE && !--this->noteLength)
+	if (trackFlags[ToIntegral(TrackUpdateFlag::Length)])
+	{
+		ChannelState st = this->state;
+		if (st > ChannelState::Start)
+		{
+			if (st < ChannelState::Release && !--this->noteLength)
 				this->Release();
 			if (this->manualSweep && this->sweepCnt < this->sweepLen)
 				++this->sweepCnt;
 		}
 	}
-	if (trackFlags[TUF_VOL])
+	if (trackFlags[ToIntegral(TrackUpdateFlag::Volume)])
 	{
 		this->UpdateVol(trk);
-		this->flags.set(CF_UPDVOL);
-	}
-	if (trackFlags[TUF_PAN])
+		this->flags.set(ToIntegral(ChannelFlag::UpdateVolume));
+	}
+	if (trackFlags[ToIntegral(TrackUpdateFlag::Pan)])
 	{
 		this->UpdatePan(trk);
-		this->flags.set(CF_UPDPAN);
-	}
-	if (trackFlags[TUF_TIMER])
+		this->flags.set(ToIntegral(ChannelFlag::UpdatePan));
+	}
+	if (trackFlags[ToIntegral(TrackUpdateFlag::Timer)])
 	{
 		this->UpdateTune(trk);
-		this->flags.set(CF_UPDTMR);
-	}
-	if (trackFlags[TUF_MOD])
+		this->flags.set(ToIntegral(ChannelFlag::UpdateTimer));
+	}
+	if (trackFlags[ToIntegral(TrackUpdateFlag::Modulation)])
 	{
 		int oldType = this->modType;
 		int newType = trk.modType;
 		this->UpdateMod(trk);
 		if (oldType != newType)
 		{
-			this->flags.set(getModFlag(oldType));
-			this->flags.set(getModFlag(newType));
-		}
-	}
-}
-
-static const uint16_t getpitchtbl[] =
+			this->flags.set(ToIntegral(getModFlag(oldType)));
+			this->flags.set(ToIntegral(getModFlag(newType)));
+		}
+	}
+}
+
+static const std::uint16_t getpitchtbl[] =
 {
 	0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F,
 	0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D,
@@ -324,7 +331,7 @@
 	0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A
 };
 
-static const uint8_t getvoltbl[] =
+static const std::uint8_t getvoltbl[] =
 {
 	0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
 	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
@@ -375,7 +382,7 @@
 };
 
 // This function was obtained through disassembly of Ninty's sound driver
-static inline uint16_t Timer_Adjust(uint16_t basetmr, int pitch)
+static inline std::uint16_t Timer_Adjust(std::uint16_t basetmr, int pitch)
 {
 	int shift = 0;
 	pitch = -pitch;
@@ -392,7 +399,7 @@
 		pitch -= 0x300;
 	}
 
-	uint64_t tmr = static_cast<uint64_t>(basetmr) * (static_cast<uint32_t>(getpitchtbl[pitch]) + 0x10000);
+	std::uint64_t tmr = static_cast<std::uint64_t>(basetmr) * (static_cast<std::uint32_t>(getpitchtbl[pitch]) + 0x10000);
 	shift -= 16;
 	if (shift <= 0)
 		tmr >>= -shift;
@@ -409,7 +416,7 @@
 		return 0x10;
 	if (tmr > 0xFFFF)
 		return 0xFFFF;
-	return static_cast<uint16_t>(tmr);
+	return static_cast<std::uint16_t>(tmr);
 }
 
 static inline int calcVolDivShift(int x)
@@ -427,35 +434,35 @@
 void Channel::Update()
 {
 	// Kill active channels that aren't physically active
-	if (this->state > CS_START && !this->reg.enable)
+	if (this->state > ChannelState::Start && !this->reg.enable)
 	{
 		this->Kill();
 		return;
 	}
 
-	bool bNotInSustain = this->state != CS_SUSTAIN;
-	bool bInStart = this->state == CS_START;
+	bool bNotInSustain = this->state != ChannelState::Sustain;
+	bool bInStart = this->state == ChannelState::Start;
 	bool bPitchSweep = this->sweepPitch && this->sweepLen && this->sweepCnt <= this->sweepLen;
 	bool bModulation = !!this->modDepth;
-	bool bVolNeedUpdate = this->flags[CF_UPDVOL] || bNotInSustain;
-	bool bPanNeedUpdate = this->flags[CF_UPDPAN] || bInStart;
-	bool bTmrNeedUpdate = this->flags[CF_UPDTMR] || bInStart || bPitchSweep;
+	bool bVolNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdateVolume)] || bNotInSustain;
+	bool bPanNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdatePan)] || bInStart;
+	bool bTmrNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdateTimer)] || bInStart || bPitchSweep;
 	int modParam = 0;
 
 	switch (this->state)
 	{
-		case CS_NONE:
+		case ChannelState::None:
 			return;
-		case CS_START:
+		case ChannelState::Start:
 			this->reg.ClearControlRegister();
 			this->reg.source = this->tempReg.SOURCE;
 			this->reg.loopStart = this->tempReg.REPEAT_POINT;
 			this->reg.length = this->tempReg.LENGTH;
 			this->reg.totalLength = this->reg.loopStart + this->reg.length;
 			this->ampl = AMPL_THRESHOLD;
-			this->state = CS_ATTACK;
+			this->state = ChannelState::Attack;
 			// fallthrough
-		case CS_ATTACK:
+		case ChannelState::Attack:
 		{
 			int newAmpl = this->ampl;
 			int oldAmpl = this->ampl >> 7;
@@ -464,21 +471,21 @@
 			while ((newAmpl >> 7) == oldAmpl);
 			this->ampl = newAmpl;
 			if (!this->ampl)
-				this->state = CS_DECAY;
+				this->state = ChannelState::Decay;
 			break;
 		}
-		case CS_DECAY:
+		case ChannelState::Decay:
 		{
 			this->ampl -= static_cast<int>(this->decayRate);
 			int sustLvl = Cnv_Sust(this->sustainLvl) << 7;
 			if (this->ampl <= sustLvl)
 			{
 				this->ampl = sustLvl;
-				this->state = CS_SUSTAIN;
+				this->state = ChannelState::Sustain;
 			}
 			break;
 		}
-		case CS_RELEASE:
+		case ChannelState::Release:
 			this->ampl -= static_cast<int>(this->releaseRate);
 			if (this->ampl <= AMPL_THRESHOLD)
 			{
@@ -511,12 +518,12 @@
 		modParam = Cnv_Sine(this->modCounter >> 8) * this->modRange * this->modDepth; // 7.14
 
 		if (this->modType == 1)
-			modParam = static_cast<int64_t>(modParam * 60) >> 14; // vol: adjust range to 6dB = 60cB (no fractional bits)
+			modParam = static_cast<std::int64_t>(modParam * 60) >> 14; // vol: adjust range to 6dB = 60cB (no fractional bits)
 		else
 			modParam >>= 8; // tmr/pan: adjust to 7.6
 
 		// Update the modulation variables
-		uint32_t counter = this->modCounter + (this->modSpeed << 6);
+		std::uint32_t counter = this->modCounter + (this->modSpeed << 6);
 		while (counter >= 0x8000)
 			counter -= 0x8000;
 		this->modCounter = counter;
@@ -531,22 +538,22 @@
 		{
 			int len = this->sweepLen;
 			int cnt = this->sweepCnt;
-			totalAdj += (static_cast<int64_t>(this->sweepPitch) * (len - cnt)) / len;
+			totalAdj += (static_cast<std::int64_t>(this->sweepPitch) * (len - cnt)) / len;
 			if (!this->manualSweep)
 				++this->sweepCnt;
 		}
-		uint16_t tmr = this->tempReg.TIMER;
+		std::uint16_t tmr = this->tempReg.TIMER;
 
 		if (totalAdj)
 			tmr = Timer_Adjust(tmr, totalAdj);
 		this->reg.timer = -tmr;
 		this->reg.sampleIncrease = (ARM7_CLOCK / static_cast<double>(this->ply->sampleRate * 2)) / (0x10000 - this->reg.timer);
-		this->flags.reset(CF_UPDTMR);
+		this->flags.reset(ToIntegral(ChannelFlag::UpdateTimer));
 	}
 
 	if (bVolNeedUpdate || bPanNeedUpdate)
 	{
-		uint32_t cr = this->tempReg.CR;
+		std::uint32_t cr = this->tempReg.CR;
 		if (bVolNeedUpdate)
 		{
 			int totalVol = this->ampl >> 7;
@@ -569,7 +576,7 @@
 
 			this->vol = ((cr & SOUND_VOL(0x7F)) << 4) >> calcVolDivShift((cr & SOUND_VOLDIV(3)) >> 8);
 
-			this->flags.reset(CF_UPDVOL);
+			this->flags.reset(ToIntegral(ChannelFlag::UpdateVolume));
 		}
 
 		if (bPanNeedUpdate)
@@ -583,7 +590,7 @@
 
 			cr &= ~SOUND_PAN(0x7F);
 			cr |= SOUND_PAN(realPan);
-			this->flags.reset(CF_UPDPAN);
+			this->flags.reset(ToIntegral(ChannelFlag::UpdatePan));
 		}
 
 		this->tempReg.CR = cr;
@@ -591,7 +598,7 @@
 	}
 }
 
-static const int16_t wavedutytbl[8][8] =
+static const std::int16_t wavedutytbl[8][8] =
 {
 	{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF },
 	{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF },
@@ -606,14 +613,14 @@
 // Linear interpolation code originally from DeSmuME
 // Legrange comes from Olli Niemitalo:
 // http://www.student.oulu.fi/~oniemita/dsp/deip.pdf
-int32_t Channel::Interpolate()
+std::int32_t Channel::Interpolate()
 {
 	double ratio = this->reg.samplePosition;
-	ratio -= static_cast<int32_t>(ratio);
+	ratio -= static_cast<std::int32_t>(ratio);
 
 	const auto &data = this->ringBuffer.GetBuffer();
 
-	if (this->ply->interpolation == INTERPOLATION_SINC)
+	if (this->ply->interpolation == Interpolation::Sinc)
 	{
 		double kernel[SINC_WIDTH * 2], kernel_sum = 0.0;
 		int i = SINC_WIDTH, shift = static_cast<int>(std::floor(ratio * SINC_RESOLUTION));
@@ -629,13 +636,13 @@
 		double sum = 0.0;
 		for (i = 0; i < static_cast<int>(SINC_WIDTH * 2); ++i)
 			sum += data[i - static_cast<int>(SINC_WIDTH) + 1] * kernel[i];
-		return static_cast<int32_t>(sum / kernel_sum);
-	}
-	else if (this->ply->interpolation > INTERPOLATION_LINEAR)
+		return static_cast<std::int32_t>(sum / kernel_sum);
+	}
+	else if (this->ply->interpolation > Interpolation::Linear)
 	{
 		double c0, c1, c2, c3, c4, c5;
 
-		if (this->ply->interpolation == INTERPOLATION_6POINTLEGRANGE)
+		if (this->ply->interpolation == Interpolation::SixPointLegrange)
 		{
 			ratio -= 0.5;
 			double even1 = data[-2] + data[3], odd1 = data[-2] - data[3];
@@ -647,30 +654,30 @@
 			c3 = 1 / 48.0 * odd1 - 13 / 48.0 * odd2 + 17 / 24.0 * odd3;
 			c4 = 1 / 48.0 * even1 - 0.0625 * even2 + 1 / 24.0 * even3;
 			c5 = 1 / 24.0 * odd2 - 1 / 12.0 * odd3 - 1 / 120.0 * odd1;
-			return static_cast<int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0);
-		}
-		else // INTERPOLATION_4POINTLEAGRANGE
+			return static_cast<std::int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0);
+		}
+		else // 4-Point Legrange
 		{
 			c0 = data[0];
 			c1 = data[1] - 1 / 3.0 * data[-1] - 0.5 * data[0] - 1 / 6.0 * data[2];
 			c2 = 0.5 * (data[-1] + data[1]) - data[0];
 			c3 = 1 / 6.0 * (data[2] - data[-1]) + 0.5 * (data[0] - data[1]);
-			return static_cast<int32_t>(((c3 * ratio + c2) * ratio + c1) * ratio + c0);
-		}
-	}
-	else // INTERPOLATION_LINEAR
-		return static_cast<int32_t>(data[0] + ratio * (data[1] - data[0]));
-}
-
-int32_t Channel::GenerateSample()
+			return static_cast<std::int32_t>(((c3 * ratio + c2) * ratio + c1) * ratio + c0);
+		}
+	}
+	else // Linear
+		return static_cast<std::int32_t>(data[0] + ratio * (data[1] - data[0]));
+}
+
+std::int32_t Channel::GenerateSample()
 {
 	if (this->reg.samplePosition < 0)
 		return 0;
 
 	if (this->reg.format != 3)
 	{
-		if (this->ply->interpolation == INTERPOLATION_NONE)
-			return this->reg.source->dataptr[static_cast<uint32_t>(this->reg.samplePosition)];
+		if (this->ply->interpolation == Interpolation::None)
+			return this->reg.source->dataptr[static_cast<std::uint32_t>(this->reg.samplePosition)];
 		else
 			return this->Interpolate();
 	}
@@ -679,13 +686,13 @@
 		if (this->chnId < 8)
 			return 0;
 		else if (this->chnId < 14)
-			return wavedutytbl[this->reg.waveDuty][static_cast<uint32_t>(this->reg.samplePosition) & 0x7];
+			return wavedutytbl[this->reg.waveDuty][static_cast<std::uint32_t>(this->reg.samplePosition) & 0x7];
 		else
 		{
-			if (this->reg.psgLastCount != static_cast<uint32_t>(this->reg.samplePosition))
+			if (this->reg.psgLastCount != static_cast<std::uint32_t>(this->reg.samplePosition))
 			{
-				uint32_t max = static_cast<uint32_t>(this->reg.samplePosition);
-				for (uint32_t i = this->reg.psgLastCount; i < max; ++i)
+				std::uint32_t max = static_cast<std::uint32_t>(this->reg.samplePosition);
+				for (std::uint32_t i = this->reg.psgLastCount; i < max; ++i)
 				{
 					if (this->reg.psgX & 0x1)
 					{
@@ -699,7 +706,7 @@
 					}
 				}
 
-				this->reg.psgLastCount = static_cast<uint32_t>(this->reg.samplePosition);
+				this->reg.psgLastCount = static_cast<std::uint32_t>(this->reg.samplePosition);
 			}
 
 			return this->reg.psgLast;
@@ -717,17 +724,17 @@
 		{
 			this->ringBuffer.Clear();
 			this->ringBuffer.bufferPos += SINC_WIDTH + 1;
-			auto preData = std::vector<int16_t>(SINC_WIDTH + 1, this->reg.source->dataptr[0]);
+			auto preData = std::vector<std::int16_t>(SINC_WIDTH + 1, this->reg.source->dataptr[0]);
 			this->ringBuffer.PushSamples(&preData[0], SINC_WIDTH + 1);
 			if (this->reg.totalLength < SINC_WIDTH + 1)
 			{
 				this->ringBuffer.PushSamples(&this->reg.source->dataptr[0], this->reg.totalLength);
 				if (this->reg.repeatMode == 1)
 				{
-					size_t samplesLeft = SINC_WIDTH + 1 - this->reg.totalLength;
+					std::size_t samplesLeft = SINC_WIDTH + 1 - this->reg.totalLength;
 					while (samplesLeft)
 					{
-						size_t samplesToPush = std::min(samplesLeft, this->reg.length);
+						std::size_t samplesToPush = std::min(samplesLeft, this->reg.length);
 						this->ringBuffer.PushSamples(&this->reg.source->dataptr[this->reg.loopStart], samplesToPush);
 						samplesLeft -= samplesToPush;
 					}
@@ -738,8 +745,8 @@
 		}
 		if (this->reg.samplePosition >= 0)
 		{
-			uint32_t loc = static_cast<uint32_t>(this->reg.samplePosition) + SINC_WIDTH + 1;
-			uint32_t newloc = static_cast<uint32_t>(samplePosition) + SINC_WIDTH + 1;
+			std::uint32_t loc = static_cast<std::uint32_t>(this->reg.samplePosition) + SINC_WIDTH + 1;
+			std::uint32_t newloc = static_cast<std::uint32_t>(samplePosition) + SINC_WIDTH + 1;
 
 			if (this->reg.repeatMode == 1)
 			{

--- a/src/in_ncsf/SSEQPlayer/Channel.h
+++ b/src/in_ncsf/SSEQPlayer/Channel.h
@@ -14,9 +14,13 @@
 
 #include <algorithm>
 #include <bitset>
+#include <cstddef>
 #include <cstdint>
-#include "SWAV.h"
-#include "Track.h"
+#include "common.h"
+#include "consts.h"
+
+struct SWAV;
+struct Track;
 
 /*
  * This structure is meant to be similar to what is stored in the actual
@@ -27,41 +31,41 @@
 struct NDSSoundRegister
 {
 	// Control Register
-	uint8_t volumeMul;
-	uint8_t volumeDiv;
-	uint8_t panning;
-	uint8_t waveDuty;
-	uint8_t repeatMode;
-	uint8_t format;
+	std::uint8_t volumeMul;
+	std::uint8_t volumeDiv;
+	std::uint8_t panning;
+	std::uint8_t waveDuty;
+	std::uint8_t repeatMode;
+	std::uint8_t format;
 	bool enable;
 
 	// Data Source Register
 	const SWAV *source;
 
 	// Timer Register
-	uint16_t timer;
+	std::uint16_t timer;
 
 	// PSG Handling, not a DS register
-	uint16_t psgX;
-	int16_t psgLast;
-	uint32_t psgLastCount;
+	std::uint16_t psgX;
+	std::int16_t psgLast;
+	std::uint32_t psgLastCount;
 
 	// The following are taken from DeSmuME
 	double samplePosition;
 	double sampleIncrease;
 
 	// Loopstart Register
-	uint32_t loopStart;
+	std::uint32_t loopStart;
 
 	// Length Register
-	uint32_t length;
-
-	uint32_t totalLength;
+	std::uint32_t length;
+
+	std::uint32_t totalLength;
 
 	NDSSoundRegister();
 
 	void ClearControlRegister();
-	void SetControlRegister(uint32_t reg);
+	void SetControlRegister(std::uint32_t reg);
 };
 
 /*
@@ -72,10 +76,10 @@
  */
 struct TempSndReg
 {
-	uint32_t CR;
+	std::uint32_t CR;
 	const SWAV *SOURCE;
-	uint16_t TIMER;
-	uint32_t REPEAT_POINT, LENGTH;
+	std::uint16_t TIMER;
+	std::uint32_t REPEAT_POINT, LENGTH;
 
 	TempSndReg();
 };
@@ -95,10 +99,10 @@
  * accessing the SWAVs samples and also doesn't use 0s before the
  * start of the SWAV or use 0s after the end of a non-looping SWAV.
  */
-template<size_t N> struct RingBuffer
-{
-	int16_t buffer[N * 2];
-	size_t bufferPos, getPos;
+template<std::size_t N> struct RingBuffer
+{
+	std::int16_t buffer[N * 2];
+	std::size_t bufferPos, getPos;
 
 	RingBuffer() : bufferPos(N / 2), getPos(N / 2)
 	{
@@ -109,7 +113,7 @@
 		std::fill_n(&this->buffer[0], N * 2, 0);
 		this->bufferPos = this->getPos = N / 2;
 	}
-	void PushSample(int16_t sample)
+	void PushSample(std::int16_t sample)
 	{
 		this->buffer[this->bufferPos] = sample;
 		if (this->bufferPos >= N)
@@ -120,23 +124,23 @@
 		if (this->bufferPos >= N * 3 / 2)
 			this->bufferPos -= N;
 	}
-	void PushSamples(const int16_t *samples, size_t size)
+	void PushSamples(const std::int16_t *samples, std::size_t size)
 	{
 		if (this->bufferPos + size > N * 3 / 2)
 		{
-			size_t free = N * 3 / 2 - this->bufferPos;
+			std::size_t free = N * 3 / 2 - this->bufferPos;
 			std::copy_n(&samples[0], free, &this->buffer[this->bufferPos]);
 			std::copy(&samples[free], &samples[size], &this->buffer[N / 2]);
 		}
 		else
 			std::copy_n(&samples[0], size, &this->buffer[this->bufferPos]);
-		size_t rightFree = this->bufferPos < N ? N - this->bufferPos : 0;
+		std::size_t rightFree = this->bufferPos < N ? N - this->bufferPos : 0;
 		if (rightFree < size)
 		{
 			if (!rightFree)
 			{
-				size_t leftStart = this->bufferPos - N;
-				size_t leftSize = std::min(N / 2 - leftStart, size);
+				std::size_t leftStart = this->bufferPos - N;
+				std::size_t leftSize = std::min(N / 2 - leftStart, size);
 				std::copy_n(&samples[0], leftSize, &this->buffer[leftStart]);
 				if (leftSize < size)
 					std::copy(&samples[leftSize], &samples[size], &this->buffer[N * 3 / 2]);
@@ -153,7 +157,7 @@
 		if (this->bufferPos >= N * 3 / 2)
 			this->bufferPos -= N;
 	}
-	const int16_t *GetBuffer() const
+	const std::int16_t *GetBuffer() const
 	{
 		return &this->buffer[this->getPos];
 	}
@@ -167,35 +171,35 @@
 
 struct Channel
 {
-	int8_t chnId;
+	std::int8_t chnId;
 
 	TempSndReg tempReg;
-	uint8_t state;
-	int8_t trackId; // -1 = none
-	uint8_t prio;
+	ChannelState state;
+	std::int8_t trackId; // -1 = none
+	std::uint8_t prio;
 	bool manualSweep;
 
-	std::bitset<CF_BITS> flags;
-	int8_t pan; // -64 .. 63
-	int16_t extAmpl;
-
-	int16_t velocity;
-	int8_t extPan;
-	uint8_t key;
+	std::bitset<ToIntegral(ChannelFlag::Bits)> flags;
+	std::int8_t pan; // -64 .. 63
+	std::int16_t extAmpl;
+
+	std::int16_t velocity;
+	std::int8_t extPan;
+	std::uint8_t key;
 
 	int ampl; // 7 fractionary bits
 	int extTune; // in 64ths of a semitone
 
-	uint8_t orgKey;
-
-	uint8_t modType, modSpeed, modDepth, modRange;
-	uint16_t modDelay, modDelayCnt, modCounter;
-
-	uint32_t sweepLen, sweepCnt;
-	int16_t sweepPitch;
-
-	uint8_t attackLvl, sustainLvl;
-	uint16_t decayRate, releaseRate;
+	std::uint8_t orgKey;
+
+	std::uint8_t modType, modSpeed, modDepth, modRange;
+	std::uint16_t modDelay, modDelayCnt, modCounter;
+
+	std::uint32_t sweepLen, sweepCnt;
+	std::int16_t sweepPitch;
+
+	std::uint8_t attackLvl, sustainLvl;
+	std::uint16_t decayRate, releaseRate;
 
 	/*
 	 * These were originally global variables in FeOS Sound System, but
@@ -203,7 +207,7 @@
 	 * into this class.
 	 */
 	int noteLength;
-	uint16_t vol;
+	std::uint16_t vol;
 
 	const Player *ply;
 	NDSSoundRegister reg;
@@ -234,8 +238,8 @@
 	void Kill();
 	void UpdateTrack();
 	void Update();
-	int32_t Interpolate();
-	int32_t GenerateSample();
+	std::int32_t Interpolate();
+	std::int32_t GenerateSample();
 	void IncrementSample();
 };
 

--- a/src/in_ncsf/SSEQPlayer/FATSection.cpp
+++ b/src/in_ncsf/SSEQPlayer/FATSection.cpp
@@ -7,7 +7,9 @@
  */
 
 #include <stdexcept>
+#include <cstdint>
 #include "FATSection.h"
+#include "common.h"
 
 FATRecord::FATRecord() : offset(0)
 {
@@ -15,9 +17,9 @@
 
 void FATRecord::Read(PseudoFile &file)
 {
-	this->offset = file.ReadLE<uint32_t>();
-	file.ReadLE<uint32_t>(); // size
-	uint32_t reserved[2];
+	this->offset = file.ReadLE<std::uint32_t>();
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t reserved[2];
 	file.ReadLE(reserved);
 }
 
@@ -27,14 +29,14 @@
 
 void FATSection::Read(PseudoFile &file)
 {
-	int8_t type[4];
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "FAT "))
 		throw std::runtime_error("SDAT FAT Section invalid");
-	file.ReadLE<uint32_t>(); // size
-	uint32_t count = file.ReadLE<uint32_t>();
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t count = file.ReadLE<std::uint32_t>();
 	this->records.resize(count);
-	for (uint32_t i = 0; i < count; ++i)
+	for (std::uint32_t i = 0; i < count; ++i)
 		this->records[i].Read(file);
 }
 

--- a/src/in_ncsf/SSEQPlayer/FATSection.h
+++ b/src/in_ncsf/SSEQPlayer/FATSection.h
@@ -8,11 +8,14 @@
 
 #pragma once
 
-#include "common.h"
+#include <vector>
+#include <cstdint>
+
+struct PseudoFile;
 
 struct FATRecord
 {
-	uint32_t offset;
+	std::uint32_t offset;
 
 	FATRecord();
 

--- a/src/in_ncsf/SSEQPlayer/INFOEntry.cpp
+++ b/src/in_ncsf/SSEQPlayer/INFOEntry.cpp
@@ -6,7 +6,10 @@
  * http://www.feshrine.net/hacking/doc/nds-sdat.html
  */
 
+#include <algorithm>
+#include <cstdint>
 #include "INFOEntry.h"
+#include "common.h"
 
 INFOEntrySEQ::INFOEntrySEQ() : fileID(0), bank(0), vol(0), ply(0)
 {
@@ -14,14 +17,14 @@
 
 void INFOEntrySEQ::Read(PseudoFile &file)
 {
-	this->fileID = file.ReadLE<uint32_t>();
-	this->bank = file.ReadLE<uint16_t>();
-	this->vol = file.ReadLE<uint8_t>();
+	this->fileID = file.ReadLE<std::uint32_t>();
+	this->bank = file.ReadLE<std::uint16_t>();
+	this->vol = file.ReadLE<std::uint8_t>();
 	if (!this->vol)
 		this->vol = 0x7F; // Prevents nothing for volume
-	file.ReadLE<uint8_t>(); // cpr
-	file.ReadLE<uint8_t>(); // ppr
-	this->ply = file.ReadLE<uint8_t>();
+	file.ReadLE<std::uint8_t>(); // cpr
+	file.ReadLE<std::uint8_t>(); // ppr
+	this->ply = file.ReadLE<std::uint8_t>();
 }
 
 INFOEntryBANK::INFOEntryBANK() : fileID(0)
@@ -31,7 +34,7 @@
 
 void INFOEntryBANK::Read(PseudoFile &file)
 {
-	this->fileID = file.ReadLE<uint32_t>();
+	this->fileID = file.ReadLE<std::uint32_t>();
 	file.ReadLE(this->waveArc);
 }
 
@@ -41,7 +44,7 @@
 
 void INFOEntryWAVEARC::Read(PseudoFile &file)
 {
-	this->fileID = file.ReadLE<uint32_t>();
+	this->fileID = file.ReadLE<std::uint32_t>();
 }
 
 INFOEntryPLAYER::INFOEntryPLAYER() : channelMask(0)
@@ -50,8 +53,8 @@
 
 void INFOEntryPLAYER::Read(PseudoFile &file)
 {
-	file.ReadLE<uint16_t>(); // maxSeqs
-	this->channelMask = file.ReadLE<uint16_t>();
-	file.ReadLE<uint32_t>(); // heapSize
+	file.ReadLE<std::uint16_t>(); // maxSeqs
+	this->channelMask = file.ReadLE<std::uint16_t>();
+	file.ReadLE<std::uint32_t>(); // heapSize
 }
 

--- a/src/in_ncsf/SSEQPlayer/INFOEntry.h
+++ b/src/in_ncsf/SSEQPlayer/INFOEntry.h
@@ -8,7 +8,9 @@
 
 #pragma once
 
-#include "common.h"
+#include <cstdint>
+
+struct PseudoFile;
 
 struct INFOEntry
 {
@@ -21,10 +23,10 @@
 
 struct INFOEntrySEQ : INFOEntry
 {
-	uint32_t fileID;
-	uint16_t bank;
-	uint8_t vol;
-	uint8_t ply;
+	std::uint32_t fileID;
+	std::uint16_t bank;
+	std::uint8_t vol;
+	std::uint8_t ply;
 
 	INFOEntrySEQ();
 
@@ -33,8 +35,8 @@
 
 struct INFOEntryBANK : INFOEntry
 {
-	uint32_t fileID;
-	uint16_t waveArc[4];
+	std::uint32_t fileID;
+	std::uint16_t waveArc[4];
 
 	INFOEntryBANK();
 
@@ -43,7 +45,7 @@
 
 struct INFOEntryWAVEARC : INFOEntry
 {
-	uint32_t fileID;
+	std::uint32_t fileID;
 
 	INFOEntryWAVEARC();
 
@@ -52,7 +54,7 @@
 
 struct INFOEntryPLAYER : INFOEntry
 {
-	uint16_t channelMask;
+	std::uint16_t channelMask;
 
 	INFOEntryPLAYER();
 

--- a/src/in_ncsf/SSEQPlayer/INFOSection.cpp
+++ b/src/in_ncsf/SSEQPlayer/INFOSection.cpp
@@ -8,18 +8,20 @@
 
 #include <stdexcept>
 #include <vector>
+#include <cstdint>
 #include "INFOSection.h"
+#include "common.h"
 
 template<typename T> INFORecord<T>::INFORecord() : entries()
 {
 }
 
-template<typename T> void INFORecord<T>::Read(PseudoFile &file, uint32_t startOffset)
+template<typename T> void INFORecord<T>::Read(PseudoFile &file, std::uint32_t startOffset)
 {
-	uint32_t count = file.ReadLE<uint32_t>();
-	auto entryOffsets = std::vector<uint32_t>(count);
+	std::uint32_t count = file.ReadLE<std::uint32_t>();
+	auto entryOffsets = std::vector<std::uint32_t>(count);
 	file.ReadLE(entryOffsets);
-	for (uint32_t i = 0; i < count; ++i)
+	for (std::uint32_t i = 0; i < count; ++i)
 		if (entryOffsets[i])
 		{
 			file.pos = startOffset + entryOffsets[i];
@@ -34,13 +36,13 @@
 
 void INFOSection::Read(PseudoFile &file)
 {
-	uint32_t startOfINFO = file.pos;
-	int8_t type[4];
+	std::uint32_t startOfINFO = file.pos;
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "INFO"))
 		throw std::runtime_error("SDAT INFO Section invalid");
-	file.ReadLE<uint32_t>(); // size
-	uint32_t recordOffsets[8];
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t recordOffsets[8];
 	file.ReadLE(recordOffsets);
 	if (recordOffsets[REC_SEQ])
 	{

--- a/src/in_ncsf/SSEQPlayer/INFOSection.h
+++ b/src/in_ncsf/SSEQPlayer/INFOSection.h
@@ -9,16 +9,18 @@
 #pragma once
 
 #include <map>
+#include <cstdint>
 #include "INFOEntry.h"
-#include "common.h"
+
+struct PseudoFile;
 
 template<typename T> struct INFORecord
 {
-	std::map<uint32_t, T> entries;
+	std::map<std::uint32_t, T> entries;
 
 	INFORecord();
 
-	void Read(PseudoFile &file, uint32_t startOffset);
+	void Read(PseudoFile &file, std::uint32_t startOffset);
 };
 
 struct INFOSection

--- a/src/in_ncsf/SSEQPlayer/NDSStdHeader.cpp
+++ b/src/in_ncsf/SSEQPlayer/NDSStdHeader.cpp
@@ -6,8 +6,11 @@
  * http://www.feshrine.net/hacking/doc/nds-sdat.html
  */
 
+#include <algorithm>
 #include <stdexcept>
+#include <cstdint>
 #include "NDSStdHeader.h"
+#include "common.h"
 
 NDSStdHeader::NDSStdHeader() : magic(0)
 {
@@ -17,13 +20,13 @@
 void NDSStdHeader::Read(PseudoFile &file)
 {
 	file.ReadLE(this->type);
-	this->magic = file.ReadLE<uint32_t>();
-	file.ReadLE<uint32_t>(); // file size
-	file.ReadLE<uint16_t>(); // structure size
-	file.ReadLE<uint16_t>(); // # of blocks
+	this->magic = file.ReadLE<std::uint32_t>();
+	file.ReadLE<std::uint32_t>(); // file size
+	file.ReadLE<std::uint16_t>(); // structure size
+	file.ReadLE<std::uint16_t>(); // # of blocks
 }
 
-void NDSStdHeader::Verify(const std::string &typeToCheck, uint32_t magicToCheck)
+void NDSStdHeader::Verify(const std::string &typeToCheck, std::uint32_t magicToCheck)
 {
 	if (!VerifyHeader(this->type, typeToCheck) || this->magic != magicToCheck)
 		throw std::runtime_error("NDS Standard Header for " + typeToCheck + " invalid");

--- a/src/in_ncsf/SSEQPlayer/NDSStdHeader.h
+++ b/src/in_ncsf/SSEQPlayer/NDSStdHeader.h
@@ -8,16 +8,19 @@
 
 #pragma once
 
-#include "common.h"
+#include <string>
+#include <cstdint>
+
+struct PseudoFile;
 
 struct NDSStdHeader
 {
-	int8_t type[4];
-	uint32_t magic;
+	std::int8_t type[4];
+	std::uint32_t magic;
 
 	NDSStdHeader();
 
 	void Read(PseudoFile &file);
-	void Verify(const std::string &typeToCheck, uint32_t magicToCheck);
+	void Verify(const std::string &typeToCheck, std::uint32_t magicToCheck);
 };
 

--- a/src/in_ncsf/SSEQPlayer/Player.cpp
+++ b/src/in_ncsf/SSEQPlayer/Player.cpp
@@ -7,14 +7,18 @@
  * https://github.com/fincs/FSS
  */
 
+#include <algorithm>
+#include <cstdint>
 #include "Player.h"
+#include "SSEQ.h"
 #include "common.h"
+#include "consts.h"
 
 Player::Player() : prio(0), nTracks(0), tempo(0), tempoCount(0), tempoRate(0), masterVol(0), sseqVol(0), sseq(nullptr), allowedChannels(0), sampleRate(0),
-	interpolation(INTERPOLATION_NONE)
+	interpolation(Interpolation::None)
 {
 	std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, 0);
-	for (int8_t i = 0; i < 16; ++i)
+	for (std::int8_t i = 0; i < 16; ++i)
 	{
 		this->channels[i].chnId = i;
 		this->channels[i].ply = this;
@@ -55,7 +59,7 @@
 // Original FSS Function: Player_FreeTracks
 void Player::FreeTracks()
 {
-	for (uint8_t i = 0; i < this->nTracks; ++i)
+	for (std::uint8_t i = 0; i < this->nTracks; ++i)
 		this->tracks[this->trackIds[i]].Free();
 	this->nTracks = 0;
 }
@@ -64,14 +68,14 @@
 void Player::Stop(bool bKillSound)
 {
 	this->ClearState();
-	for (uint8_t i = 0; i < this->nTracks; ++i)
+	for (std::uint8_t i = 0; i < this->nTracks; ++i)
 	{
-		uint8_t trackId = this->trackIds[i];
+		std::uint8_t trackId = this->trackIds[i];
 		this->tracks[trackId].ClearState();
 		for (int j = 0; j < 16; ++j)
 		{
 			Channel &chn = this->channels[j];
-			if (chn.state != CS_NONE && chn.trackId == trackId)
+			if (chn.state != ChannelState::None && chn.trackId == trackId)
 			{
 				if (bKillSound)
 					chn.Kill();
@@ -84,16 +88,16 @@
 }
 
 // Original FSS Function: Chn_Alloc
-int Player::ChannelAlloc(int type, int priority)
+int Player::ChannelAlloc(ChannelAllocateType type, int priority)
 {
-	static const uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
-	static const uint8_t psgChnArray[] = { 8, 9, 10, 11, 12, 13 };
-	static const uint8_t noiseChnArray[] = { 14, 15 };
-	static const uint8_t arraySizes[] = { sizeof(pcmChnArray), sizeof(psgChnArray), sizeof(noiseChnArray) };
-	static const uint8_t *const arrayArray[] = { pcmChnArray, psgChnArray, noiseChnArray };
+	static const std::uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
+	static const std::uint8_t psgChnArray[] = { 8, 9, 10, 11, 12, 13 };
+	static const std::uint8_t noiseChnArray[] = { 14, 15 };
+	static const std::uint8_t arraySizes[] = { sizeof(pcmChnArray), sizeof(psgChnArray), sizeof(noiseChnArray) };
+	static const std::uint8_t *const arrayArray[] = { pcmChnArray, psgChnArray, noiseChnArray };
 
-	auto chnArray = arrayArray[type];
-	int arraySize = arraySizes[type];
+	auto chnArray = arrayArray[ToIntegral(type)];
+	int arraySize = arraySizes[ToIntegral(type)];
 
 	int curChnNo = -1;
 	for (int i = 0; i < arraySize; ++i)
@@ -126,10 +130,10 @@
 	for (int i = 0; i < FSS_MAXTRACKS; ++i)
 	{
 		Track &thisTrk = this->tracks[i];
-		if (!thisTrk.state[TS_ALLOCBIT])
+		if (!thisTrk.state[ToIntegral(TrackState::AllocateBit)])
 		{
 			thisTrk.Zero();
-			thisTrk.state.set(TS_ALLOCBIT);
+			thisTrk.state.set(ToIntegral(TrackState::AllocateBit));
 			thisTrk.updateFlags.reset();
 			return i;
 		}
@@ -143,7 +147,7 @@
 	while (this->tempoCount >= 240)
 	{
 		this->tempoCount -= 240;
-		for (uint8_t i = 0; i < this->nTracks; ++i)
+		for (std::uint8_t i = 0; i < this->nTracks; ++i)
 			this->tracks[this->trackIds[i]].Run();
 	}
 	this->tempoCount += (static_cast<int>(this->tempo) * static_cast<int>(this->tempoRate)) >> 8;

--- a/src/in_ncsf/SSEQPlayer/Player.h
+++ b/src/in_ncsf/SSEQPlayer/Player.h
@@ -10,26 +10,29 @@
 #pragma once
 
 #include <bitset>
-#include "SSEQ.h"
+#include <cstdint>
+#include "Channel.h"
 #include "Track.h"
-#include "Channel.h"
 #include "consts.h"
+
+enum class ChannelAllocateType;
+struct SSEQ;
 
 struct Player
 {
-	uint8_t prio, nTracks;
-	uint16_t tempo, tempoCount, tempoRate /* 8.8 fixed point */;
-	int16_t masterVol, sseqVol;
+	std::uint8_t prio, nTracks;
+	std::uint16_t tempo, tempoCount, tempoRate /* 8.8 fixed point */;
+	std::int16_t masterVol, sseqVol;
 
 	const SSEQ *sseq;
 
-	uint8_t trackIds[FSS_TRACKCOUNT];
+	std::uint8_t trackIds[FSS_TRACKCOUNT];
 	Track tracks[FSS_MAXTRACKS];
 	Channel channels[16];
 	std::bitset<16> allowedChannels;
-	int16_t variables[32];
+	std::int16_t variables[32];
 
-	uint32_t sampleRate;
+	std::uint32_t sampleRate;
 	Interpolation interpolation;
 
 	Player();
@@ -38,7 +41,7 @@
 	void ClearState();
 	void FreeTracks();
 	void Stop(bool bKillSound);
-	int ChannelAlloc(int type, int prio);
+	int ChannelAlloc(ChannelAllocateType type, int prio);
 	int TrackAlloc();
 	void Run();
 	void UpdateTracks();

--- a/src/in_ncsf/SSEQPlayer/SBNK.cpp
+++ b/src/in_ncsf/SSEQPlayer/SBNK.cpp
@@ -6,48 +6,51 @@
  * http://www.feshrine.net/hacking/doc/nds-sdat.html
  */
 
+#include <algorithm>
 #include <stdexcept>
+#include <cstdint>
+#include "NDSStdHeader.h"
 #include "SBNK.h"
-#include "NDSStdHeader.h"
+#include "common.h"
 
-SBNKInstrumentRange::SBNKInstrumentRange(uint8_t lowerNote, uint8_t upperNote, int recordType) : lowNote(lowerNote), highNote(upperNote),
+SBNKInstrumentRange::SBNKInstrumentRange(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType) : lowNote(lowerNote), highNote(upperNote),
 	record(recordType), swav(0), swar(0), noteNumber(0), attackRate(0), decayRate(0), sustainLevel(0), releaseRate(0), pan(0)
 {
 }
 
 void SBNKInstrumentRange::Read(PseudoFile &file)
 {
-	this->swav = file.ReadLE<uint16_t>();
-	this->swar = file.ReadLE<uint16_t>();
-	this->noteNumber = file.ReadLE<uint8_t>();
-	this->attackRate = file.ReadLE<uint8_t>();
-	this->decayRate = file.ReadLE<uint8_t>();
-	this->sustainLevel = file.ReadLE<uint8_t>();
-	this->releaseRate = file.ReadLE<uint8_t>();
-	this->pan = file.ReadLE<uint8_t>();
+	this->swav = file.ReadLE<std::uint16_t>();
+	this->swar = file.ReadLE<std::uint16_t>();
+	this->noteNumber = file.ReadLE<std::uint8_t>();
+	this->attackRate = file.ReadLE<std::uint8_t>();
+	this->decayRate = file.ReadLE<std::uint8_t>();
+	this->sustainLevel = file.ReadLE<std::uint8_t>();
+	this->releaseRate = file.ReadLE<std::uint8_t>();
+	this->pan = file.ReadLE<std::uint8_t>();
 }
 
 SBNKInstrument::SBNKInstrument() : record(0), ranges()
 {
 }
 
-void SBNKInstrument::Read(PseudoFile &file, uint32_t startOffset)
+void SBNKInstrument::Read(PseudoFile &file, std::uint32_t startOffset)
 {
-	this->record = file.ReadLE<uint8_t>();
-	uint16_t offset = file.ReadLE<uint16_t>();
-	file.ReadLE<uint8_t>();
-	uint32_t endOfInst = file.pos;
+	this->record = file.ReadLE<std::uint8_t>();
+	std::uint16_t offset = file.ReadLE<std::uint16_t>();
+	file.ReadLE<std::uint8_t>();
+	std::uint32_t endOfInst = file.pos;
 	file.pos = startOffset + offset;
 	if (this->record)
 	{
 		if (this->record == 16)
 		{
-			uint8_t lowNote = file.ReadLE<uint8_t>();
-			uint8_t highNote = file.ReadLE<uint8_t>();
-			uint8_t num = highNote - lowNote + 1;
-			for (uint8_t i = 0; i < num; ++i)
+			std::uint8_t lowNote = file.ReadLE<std::uint8_t>();
+			std::uint8_t highNote = file.ReadLE<std::uint8_t>();
+			std::uint8_t num = highNote - lowNote + 1;
+			for (std::uint8_t i = 0; i < num; ++i)
 			{
-				uint16_t thisRecord = file.ReadLE<uint16_t>();
+				std::uint16_t thisRecord = file.ReadLE<std::uint16_t>();
 				auto range = SBNKInstrumentRange(lowNote + i, lowNote + i, thisRecord);
 				range.Read(file);
 				this->ranges.push_back(range);
@@ -55,14 +58,14 @@
 		}
 		else if (this->record == 17)
 		{
-			uint8_t thisRanges[8];
+			std::uint8_t thisRanges[8];
 			file.ReadLE(thisRanges);
-			uint8_t i = 0;
+			std::uint8_t i = 0;
 			while (i < 8 && thisRanges[i])
 			{
-				uint16_t thisRecord = file.ReadLE<uint16_t>();
-				uint8_t lowNote = i ? thisRanges[i - 1] + 1 : 0;
-				uint8_t highNote = thisRanges[i];
+				std::uint16_t thisRecord = file.ReadLE<std::uint16_t>();
+				std::uint8_t lowNote = i ? thisRanges[i - 1] + 1 : 0;
+				std::uint8_t highNote = thisRanges[i];
 				auto range = SBNKInstrumentRange(lowNote, highNote, thisRecord);
 				range.Read(file);
 				this->ranges.push_back(range);
@@ -86,20 +89,20 @@
 
 void SBNK::Read(PseudoFile &file)
 {
-	uint32_t startOfSBNK = file.pos;
+	std::uint32_t startOfSBNK = file.pos;
 	NDSStdHeader header;
 	header.Read(file);
 	header.Verify("SBNK", 0x0100FEFF);
-	int8_t type[4];
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "DATA"))
 		throw std::runtime_error("SBNK DATA structure invalid");
-	file.ReadLE<uint32_t>(); // size
-	uint32_t reserved[8];
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t reserved[8];
 	file.ReadLE(reserved);
-	uint32_t count = file.ReadLE<uint32_t>();
+	std::uint32_t count = file.ReadLE<std::uint32_t>();
 	this->instruments.resize(count);
-	for (uint32_t i = 0; i < count; ++i)
+	for (std::uint32_t i = 0; i < count; ++i)
 		this->instruments[i].Read(file, startOfSBNK);
 }
 

--- a/src/in_ncsf/SSEQPlayer/SBNK.h
+++ b/src/in_ncsf/SSEQPlayer/SBNK.h
@@ -8,37 +8,41 @@
 
 #pragma once
 
-#include "SWAR.h"
+#include <string>
+#include <vector>
+#include <cstdint>
 #include "INFOEntry.h"
-#include "common.h"
+
+struct PseudoFile;
+struct SWAR;
 
 struct SBNKInstrumentRange
 {
-	uint8_t lowNote;
-	uint8_t highNote;
-	uint16_t record;
-	uint16_t swav;
-	uint16_t swar;
-	uint8_t noteNumber;
-	uint8_t attackRate;
-	uint8_t decayRate;
-	uint8_t sustainLevel;
-	uint8_t releaseRate;
-	uint8_t pan;
+	std::uint8_t lowNote;
+	std::uint8_t highNote;
+	std::uint16_t record;
+	std::uint16_t swav;
+	std::uint16_t swar;
+	std::uint8_t noteNumber;
+	std::uint8_t attackRate;
+	std::uint8_t decayRate;
+	std::uint8_t sustainLevel;
+	std::uint8_t releaseRate;
+	std::uint8_t pan;
 
-	SBNKInstrumentRange(uint8_t lowerNote, uint8_t upperNote, int recordType);
+	SBNKInstrumentRange(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType);
 
 	void Read(PseudoFile &file);
 };
 
 struct SBNKInstrument
 {
-	uint8_t record;
+	std::uint8_t record;
 	std::vector<SBNKInstrumentRange> ranges;
 
 	SBNKInstrument();
 
-	void Read(PseudoFile &file, uint32_t startOffset);
+	void Read(PseudoFile &file, std::uint32_t startOffset);
 };
 
 struct SBNK

--- a/src/in_ncsf/SSEQPlayer/SDAT.cpp
+++ b/src/in_ncsf/SSEQPlayer/SDAT.cpp
@@ -6,25 +6,31 @@
  * http://www.feshrine.net/hacking/doc/nds-sdat.html
  */
 
+#include <stdexcept>
+#include <string>
+#include <cstdint>
+#include "FATSection.h"
+#include "INFOSection.h"
+#include "NDSStdHeader.h"
+#include "SBNK.h"
 #include "SDAT.h"
-#include "NDSStdHeader.h"
+#include "SSEQ.h"
+#include "SWAR.h"
 #include "SYMBSection.h"
-#include "INFOSection.h"
-#include "FATSection.h"
-#include "convert.h"
+#include "common.h"
 
-SDAT::SDAT(PseudoFile &file, uint32_t sseqToLoad) : sseq(), sbnk(), player()
+SDAT::SDAT(PseudoFile &file, std::uint32_t sseqToLoad) : sseq(), sbnk(), player()
 {
 	// Read sections
 	NDSStdHeader header;
 	header.Read(file);
 	header.Verify("SDAT", 0x0100FEFF);
-	uint32_t SYMBOffset = file.ReadLE<uint32_t>();
-	file.ReadLE<uint32_t>(); // SYMB size
-	uint32_t INFOOffset = file.ReadLE<uint32_t>();
-	file.ReadLE<uint32_t>(); // INFO size
-	uint32_t FATOffset = file.ReadLE<uint32_t>();
-	file.ReadLE<uint32_t>(); // FAT Size
+	std::uint32_t SYMBOffset = file.ReadLE<std::uint32_t>();
+	file.ReadLE<std::uint32_t>(); // SYMB size
+	std::uint32_t INFOOffset = file.ReadLE<std::uint32_t>();
+	file.ReadLE<std::uint32_t>(); // INFO size
+	std::uint32_t FATOffset = file.ReadLE<std::uint32_t>();
+	file.ReadLE<std::uint32_t>(); // FAT Size
 	SYMBSection symbSection;
 	if (SYMBOffset)
 	{
@@ -47,7 +53,7 @@
 	// Read SSEQ
 	if (infoSection.SEQrecord.entries.count(sseqToLoad))
 	{
-		uint16_t fileID = infoSection.SEQrecord.entries[sseqToLoad].fileID;
+		std::uint32_t fileID = infoSection.SEQrecord.entries[sseqToLoad].fileID;
 		std::string name = "SSEQ" + NumToHexString(fileID).substr(2);
 		if (SYMBOffset)
 			name = NumToHexString(sseqToLoad).substr(6) + " - " + symbSection.SEQrecord.entries[sseqToLoad];
@@ -58,7 +64,7 @@
 		this->sseq.reset(newSSEQ);
 
 		// Read SBNK for this SSEQ
-		uint16_t bank = newSSEQ->info.bank;
+		std::uint16_t bank = newSSEQ->info.bank;
 		fileID = infoSection.BANKrecord.entries[bank].fileID;
 		name = "SBNK" + NumToHexString(fileID).substr(2);
 		if (SYMBOffset)
@@ -74,7 +80,7 @@
 		for (int i = 0; i < 4; ++i)
 			if (newSBNK->info.waveArc[i] != 0xFFFF)
 			{
-				uint16_t waveArc = newSBNK->info.waveArc[i];
+				std::uint16_t waveArc = newSBNK->info.waveArc[i];
 				fileID = infoSection.WAVEARCrecord.entries[waveArc].fileID;
 				name = "SWAR" + NumToHexString(fileID).substr(2);
 				if (SYMBOffset)

--- a/src/in_ncsf/SSEQPlayer/SDAT.h
+++ b/src/in_ncsf/SSEQPlayer/SDAT.h
@@ -9,10 +9,13 @@
 #pragma once
 
 #include <memory>
+#include <cstdint>
+#include "INFOEntry.h"
+#include "SBNK.h"
 #include "SSEQ.h"
-#include "SBNK.h"
 #include "SWAR.h"
-#include "common.h"
+
+struct PseudoFile;
 
 struct SDAT
 {
@@ -21,6 +24,6 @@
 	std::unique_ptr<SWAR> swar[4];
 	INFOEntryPLAYER player;
 
-	SDAT(PseudoFile &file, uint32_t sseqToLoad);
+	SDAT(PseudoFile &file, std::uint32_t sseqToLoad);
 };
 

--- a/src/in_ncsf/SSEQPlayer/SSEQ.cpp
+++ b/src/in_ncsf/SSEQPlayer/SSEQ.cpp
@@ -7,8 +7,11 @@
  */
 
 #include <stdexcept>
+#include <string>
+#include <cstdint>
+#include "NDSStdHeader.h"
 #include "SSEQ.h"
-#include "NDSStdHeader.h"
+#include "common.h"
 
 SSEQ::SSEQ(const std::string &fn) : filename(fn), data(), bank(nullptr), info()
 {
@@ -16,16 +19,16 @@
 
 void SSEQ::Read(PseudoFile &file)
 {
-	uint32_t startOfSSEQ = file.pos;
+	std::uint32_t startOfSSEQ = file.pos;
 	NDSStdHeader header;
 	header.Read(file);
 	header.Verify("SSEQ", 0x0100FEFF);
-	int8_t type[4];
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "DATA"))
 		throw std::runtime_error("SSEQ DATA structure invalid");
-	uint32_t size = file.ReadLE<uint32_t>();
-	uint32_t dataOffset = file.ReadLE<uint32_t>();
+	std::uint32_t size = file.ReadLE<std::uint32_t>();
+	std::uint32_t dataOffset = file.ReadLE<std::uint32_t>();
 	this->data.resize(size - 12, 0);
 	file.pos = startOfSSEQ + dataOffset;
 	file.ReadLE(this->data);

--- a/src/in_ncsf/SSEQPlayer/SSEQ.h
+++ b/src/in_ncsf/SSEQPlayer/SSEQ.h
@@ -8,14 +8,18 @@
 
 #pragma once
 
-#include "SBNK.h"
+#include <string>
+#include <vector>
+#include <cstdint>
 #include "INFOEntry.h"
-#include "common.h"
+
+struct PseudoFile;
+struct SBNK;
 
 struct SSEQ
 {
 	std::string filename;
-	std::vector<uint8_t> data;
+	std::vector<std::uint8_t> data;
 
 	const SBNK *bank;
 	INFOEntrySEQ info;

--- a/src/in_ncsf/SSEQPlayer/SWAR.cpp
+++ b/src/in_ncsf/SSEQPlayer/SWAR.cpp
@@ -7,9 +7,13 @@
  */
 
 #include <stdexcept>
+#include <string>
 #include <vector>
+#include <cstdint>
+#include "NDSStdHeader.h"
 #include "SWAR.h"
-#include "NDSStdHeader.h"
+#include "SWAV.h"
+#include "common.h"
 
 SWAR::SWAR(const std::string &fn) : filename(fn), swavs(), info()
 {
@@ -17,21 +21,21 @@
 
 void SWAR::Read(PseudoFile &file)
 {
-	uint32_t startOfSWAR = file.pos;
+	std::uint32_t startOfSWAR = file.pos;
 	NDSStdHeader header;
 	header.Read(file);
 	header.Verify("SWAR", 0x0100FEFF);
-	int8_t type[4];
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "DATA"))
 		throw std::runtime_error("SWAR DATA structure invalid");
-	file.ReadLE<uint32_t>(); // size
-	uint32_t reserved[8];
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t reserved[8];
 	file.ReadLE(reserved);
-	uint32_t count = file.ReadLE<uint32_t>();
-	auto offsets = std::vector<uint32_t>(count);
+	std::uint32_t count = file.ReadLE<std::uint32_t>();
+	auto offsets = std::vector<std::uint32_t>(count);
 	file.ReadLE(offsets);
-	for (uint32_t i = 0; i < count; ++i)
+	for (std::uint32_t i = 0; i < count; ++i)
 		if (offsets[i])
 		{
 			file.pos = startOfSWAR + offsets[i];

--- a/src/in_ncsf/SSEQPlayer/SWAR.h
+++ b/src/in_ncsf/SSEQPlayer/SWAR.h
@@ -9,14 +9,17 @@
 #pragma once
 
 #include <map>
+#include <string>
+#include <cstdint>
+#include "INFOEntry.h"
 #include "SWAV.h"
-#include "INFOEntry.h"
-#include "common.h"
+
+struct PseudoFile;
 
 struct SWAR
 {
 	std::string filename;
-	std::map<uint32_t, SWAV> swavs;
+	std::map<std::uint32_t, SWAV> swavs;
 
 	INFOEntryWAVEARC info;
 

--- a/src/in_ncsf/SSEQPlayer/SWAV.cpp
+++ b/src/in_ncsf/SSEQPlayer/SWAV.cpp
@@ -6,7 +6,11 @@
  * http://www.feshrine.net/hacking/doc/nds-sdat.html
  */
 
+#include <vector>
+#include <cstddef>
+#include <cstdint>
 #include "SWAV.h"
+#include "common.h"
 
 static int ima_index_table[] =
 {
@@ -31,9 +35,9 @@
 {
 }
 
-static inline void DecodeADPCMNibble(int32_t nibble, int32_t &stepIndex, int32_t &predictedValue)
+static inline void DecodeADPCMNibble(std::int32_t nibble, std::int32_t &stepIndex, std::int32_t &predictedValue)
 {
-	int32_t step = ima_step_table[stepIndex];
+	std::int32_t step = ima_step_table[stepIndex];
 
 	stepIndex += ima_index_table[nibble];
 
@@ -42,7 +46,7 @@
 	else if (stepIndex > 88)
 		stepIndex = 88;
 
-	int32_t diff = step >> 3;
+	std::int32_t diff = step >> 3;
 
 	if (nibble & 4)
 		diff += step;
@@ -61,15 +65,15 @@
 		predictedValue = 0x7FFF;
 }
 
-void SWAV::DecodeADPCM(const uint8_t *origData, uint32_t len)
+void SWAV::DecodeADPCM(const std::uint8_t *origData, std::uint32_t len)
 {
-	int32_t predictedValue = origData[0] | (origData[1] << 8);
-	int32_t stepIndex = origData[2] | (origData[3] << 8);
+	std::int32_t predictedValue = origData[0] | (origData[1] << 8);
+	std::int32_t stepIndex = origData[2] | (origData[3] << 8);
 	auto finalData = &this->data[0];
 
-	for (uint32_t i = 0; i < len; ++i)
+	for (std::uint32_t i = 0; i < len; ++i)
 	{
-		int32_t nibble = origData[i + 4] & 0x0F;
+		std::int32_t nibble = origData[i + 4] & 0x0F;
 		DecodeADPCMNibble(nibble, stepIndex, predictedValue);
 		finalData[2 * i] = predictedValue;
 
@@ -81,14 +85,14 @@
 
 void SWAV::Read(PseudoFile &file)
 {
-	this->waveType = file.ReadLE<uint8_t>();
-	this->loop = file.ReadLE<uint8_t>();
-	this->sampleRate = file.ReadLE<uint16_t>();
-	this->time = file.ReadLE<uint16_t>();
-	this->loopOffset = file.ReadLE<uint16_t>();
-	this->nonLoopLength = file.ReadLE<uint32_t>();
-	uint32_t size = (this->loopOffset + this->nonLoopLength) * 4;
-	auto origData = std::vector<uint8_t>(size);
+	this->waveType = file.ReadLE<std::uint8_t>();
+	this->loop = file.ReadLE<std::uint8_t>();
+	this->sampleRate = file.ReadLE<std::uint16_t>();
+	this->time = file.ReadLE<std::uint16_t>();
+	this->loopOffset = file.ReadLE<std::uint16_t>();
+	this->nonLoopLength = file.ReadLE<std::uint32_t>();
+	std::uint32_t size = (this->loopOffset + this->nonLoopLength) * 4;
+	auto origData = std::vector<std::uint8_t>(size);
 	file.ReadLE(origData);
 
 	// Convert data accordingly
@@ -96,7 +100,7 @@
 	{
 		// PCM 8-bit -> PCM signed 16-bit
 		this->data.resize(size, 0);
-		for (size_t i = 0; i < size; ++i)
+		for (std::size_t i = 0; i < size; ++i)
 			this->data[i] = origData[i] << 8;
 		this->loopOffset *= 4;
 		this->nonLoopLength *= 4;
@@ -105,8 +109,8 @@
 	{
 		// PCM signed 16-bit, no conversion
 		this->data.resize(size / 2, 0);
-		for (size_t i = 0; i < size / 2; ++i)
-			this->data[i] = ReadLE<int16_t>(&origData[2 * i]);
+		for (std::size_t i = 0; i < size / 2; ++i)
+			this->data[i] = ReadLE<std::int16_t>(&origData[2 * i]);
 		this->loopOffset *= 2;
 		this->nonLoopLength *= 2;
 	}

--- a/src/in_ncsf/SSEQPlayer/SWAV.h
+++ b/src/in_ncsf/SSEQPlayer/SWAV.h
@@ -8,22 +8,25 @@
 
 #pragma once
 
-#include "common.h"
+#include <vector>
+#include <cstdint>
+
+struct PseudoFile;
 
 struct SWAV
 {
-	uint8_t waveType;
-	uint8_t loop;
-	uint16_t sampleRate;
-	uint16_t time;
-	uint32_t loopOffset;
-	uint32_t nonLoopLength;
-	std::vector<int16_t> data;
-	const int16_t *dataptr;
+	std::uint8_t waveType;
+	std::uint8_t loop;
+	std::uint16_t sampleRate;
+	std::uint16_t time;
+	std::uint32_t loopOffset;
+	std::uint32_t nonLoopLength;
+	std::vector<std::int16_t> data;
+	const std::int16_t *dataptr;
 
 	SWAV();
 
 	void Read(PseudoFile &file);
-	void DecodeADPCM(const uint8_t *origData, uint32_t len);
+	void DecodeADPCM(const std::uint8_t *origData, std::uint32_t len);
 };
 

--- a/src/in_ncsf/SSEQPlayer/SYMBSection.cpp
+++ b/src/in_ncsf/SSEQPlayer/SYMBSection.cpp
@@ -8,18 +8,20 @@
 
 #include <stdexcept>
 #include <vector>
+#include <cstdint>
 #include "SYMBSection.h"
+#include "common.h"
 
 SYMBRecord::SYMBRecord() : entries()
 {
 }
 
-void SYMBRecord::Read(PseudoFile &file, uint32_t startOffset)
+void SYMBRecord::Read(PseudoFile &file, std::uint32_t startOffset)
 {
-	uint32_t count = file.ReadLE<uint32_t>();
-	auto entryOffsets = std::vector<uint32_t>(count);
+	std::uint32_t count = file.ReadLE<uint32_t>();
+	auto entryOffsets = std::vector<std::uint32_t>(count);
 	file.ReadLE(entryOffsets);
-	for (uint32_t i = 0; i < count; ++i)
+	for (std::uint32_t i = 0; i < count; ++i)
 		if (entryOffsets[i])
 		{
 			file.pos = startOffset + entryOffsets[i];
@@ -33,13 +35,13 @@
 
 void SYMBSection::Read(PseudoFile &file)
 {
-	uint32_t startOfSYMB = file.pos;
-	int8_t type[4];
+	std::uint32_t startOfSYMB = file.pos;
+	std::int8_t type[4];
 	file.ReadLE(type);
 	if (!VerifyHeader(type, "SYMB"))
 		throw std::runtime_error("SDAT SYMB Section invalid");
-	file.ReadLE<uint32_t>(); // size
-	uint32_t recordOffsets[8];
+	file.ReadLE<std::uint32_t>(); // size
+	std::uint32_t recordOffsets[8];
 	file.ReadLE(recordOffsets);
 	if (recordOffsets[REC_SEQ])
 	{

--- a/src/in_ncsf/SSEQPlayer/SYMBSection.h
+++ b/src/in_ncsf/SSEQPlayer/SYMBSection.h
@@ -9,15 +9,17 @@
 #pragma once
 
 #include <map>
-#include "common.h"
+#include <cstdint>
+
+struct PseudoFile;
 
 struct SYMBRecord
 {
-	std::map<uint32_t, std::string> entries;
+	std::map<std::uint32_t, std::string> entries;
 
 	SYMBRecord();
 
-	void Read(PseudoFile &file, uint32_t startOffset);
+	void Read(PseudoFile &file, std::uint32_t startOffset);
 };
 
 struct SYMBSection

--- a/src/in_ncsf/SSEQPlayer/Track.cpp
+++ b/src/in_ncsf/SSEQPlayer/Track.cpp
@@ -7,10 +7,18 @@
  * https://github.com/fincs/FSS
  */
 
-#include <cstdlib>
+#include <algorithm>
+#include <functional>
+#include <cstddef>
+#include <cstdint>
+#include "Player.h"
+#include "SBNK.h"
+#include "SSEQ.h"
+#include "SWAR.h"
+#include "SWAV.h"
 #include "Track.h"
-#include "Player.h"
 #include "common.h"
+#include "consts.h"
 
 Track::Track()
 {
@@ -18,7 +26,7 @@
 }
 
 // Original FSS Function: Player_InitTrack
-void Track::Init(uint8_t handle, Player *player, const uint8_t *dataPos, int n)
+void Track::Init(std::uint8_t handle, Player *player, const std::uint8_t *dataPos, int n)
 {
 	this->trackId = handle;
 	this->num = n;
@@ -63,8 +71,8 @@
 void Track::ClearState()
 {
 	this->state.reset();
-	this->state.set(TS_ALLOCBIT);
-	this->state.set(TS_NOTEWAIT);
+	this->state.set(ToIntegral(TrackState::AllocateBit));
+	this->state.set(ToIntegral(TrackState::NoteWait));
 	this->prio = this->ply->prio + 64;
 
 	this->pos = this->startPos;
@@ -122,7 +130,7 @@
 	}
 	else if (fRecord == 17)
 	{
-		size_t reg, ranges;
+		std::size_t reg, ranges;
 		for (reg = 0, ranges = instrument.ranges.size(); reg < ranges; ++reg)
 			if (key <= instrument.ranges[reg].highNote)
 				break;
@@ -150,7 +158,7 @@
 			noteDef = &instrument.ranges[0];
 		if (fRecord == 3)
 		{
-			nCh = this->ply->ChannelAlloc(TYPE_NOISE, this->prio);
+			nCh = this->ply->ChannelAlloc(ChannelAllocateType::Noise, this->prio);
 			if (nCh < 0)
 				return -1;
 			chn = &this->ply->channels[nCh];
@@ -158,7 +166,7 @@
 		}
 		else
 		{
-			nCh = this->ply->ChannelAlloc(TYPE_PSG, this->prio);
+			nCh = this->ply->ChannelAlloc(ChannelAllocateType::PSG, this->prio);
 			if (nCh < 0)
 				return -1;
 			chn = &this->ply->channels[nCh];
@@ -171,7 +179,7 @@
 
 	if (bIsPCM)
 	{
-		nCh = this->ply->ChannelAlloc(TYPE_PCM, this->prio);
+		nCh = this->ply->ChannelAlloc(ChannelAllocateType::PCM, this->prio);
 		if (nCh < 0)
 			return -1;
 		chn = &this->ply->channels[nCh];
@@ -185,7 +193,7 @@
 		chn->reg.samplePosition = -3;
 	}
 
-	chn->state = CS_START;
+	chn->state = ChannelState::Start;
 	chn->trackId = this->trackId;
 	chn->flags.reset();
 	chn->prio = this->prio;
@@ -223,7 +231,7 @@
 	for (i = 0; i < 16; ++i)
 	{
 		chn = &this->ply->channels[i];
-		if (chn->state > CS_NONE && chn->trackId == this->trackId && chn->state != CS_RELEASE)
+		if (chn->state > ChannelState::None && chn->trackId == this->trackId && chn->state != ChannelState::Release)
 			break;
 	}
 
@@ -245,7 +253,7 @@
 	chn->UpdatePorta(*this);
 
 	this->portaKey = key;
-	chn->flags.set(CF_UPDTMR);
+	chn->flags.set(ToIntegral(ChannelFlag::UpdateTimer));
 
 	return i;
 }
@@ -256,145 +264,145 @@
 	for (int i = 0; i < 16; ++i)
 	{
 		Channel &chn = this->ply->channels[i];
-		if (chn.state > CS_NONE && chn.trackId == this->trackId && chn.state != CS_RELEASE)
+		if (chn.state > ChannelState::None && chn.trackId == this->trackId && chn.state != ChannelState::Release)
 			chn.Release();
 	}
 }
 
-enum SseqCommand
-{
-	SSEQ_CMD_ALLOCTRACK = 0xFE, // Silently ignored
-	SSEQ_CMD_OPENTRACK = 0x93,
-
-	SSEQ_CMD_REST = 0x80,
-	SSEQ_CMD_PATCH = 0x81,
-	SSEQ_CMD_PAN = 0xC0,
-	SSEQ_CMD_VOL = 0xC1,
-	SSEQ_CMD_MASTERVOL = 0xC2,
-	SSEQ_CMD_PRIO = 0xC6,
-	SSEQ_CMD_NOTEWAIT = 0xC7,
-	SSEQ_CMD_TIE = 0xC8,
-	SSEQ_CMD_EXPR = 0xD5,
-	SSEQ_CMD_TEMPO = 0xE1,
-	SSEQ_CMD_END = 0xFF,
-
-	SSEQ_CMD_GOTO = 0x94,
-	SSEQ_CMD_CALL = 0x95,
-	SSEQ_CMD_RET = 0xFD,
-	SSEQ_CMD_LOOPSTART = 0xD4,
-	SSEQ_CMD_LOOPEND = 0xFC,
-
-	SSEQ_CMD_TRANSPOSE = 0xC3,
-	SSEQ_CMD_PITCHBEND = 0xC4,
-	SSEQ_CMD_PITCHBENDRANGE = 0xC5,
-
-	SSEQ_CMD_ATTACK = 0xD0,
-	SSEQ_CMD_DECAY = 0xD1,
-	SSEQ_CMD_SUSTAIN = 0xD2,
-	SSEQ_CMD_RELEASE = 0xD3,
-
-	SSEQ_CMD_PORTAKEY = 0xC9,
-	SSEQ_CMD_PORTAFLAG = 0xCE,
-	SSEQ_CMD_PORTATIME = 0xCF,
-	SSEQ_CMD_SWEEPPITCH = 0xE3,
-
-	SSEQ_CMD_MODDEPTH = 0xCA,
-	SSEQ_CMD_MODSPEED = 0xCB,
-	SSEQ_CMD_MODTYPE = 0xCC,
-	SSEQ_CMD_MODRANGE = 0xCD,
-	SSEQ_CMD_MODDELAY = 0xE0,
-
-	SSEQ_CMD_RANDOM = 0xA0,
-	SSEQ_CMD_PRINTVAR = 0xD6,
-	SSEQ_CMD_IF = 0xA2,
-	SSEQ_CMD_FROMVAR = 0xA1,
-	SSEQ_CMD_SETVAR = 0xB0,
-	SSEQ_CMD_ADDVAR = 0xB1,
-	SSEQ_CMD_SUBVAR = 0xB2,
-	SSEQ_CMD_MULVAR = 0xB3,
-	SSEQ_CMD_DIVVAR = 0xB4,
-	SSEQ_CMD_SHIFTVAR = 0xB5,
-	SSEQ_CMD_RANDVAR = 0xB6,
-	SSEQ_CMD_CMP_EQ = 0xB8,
-	SSEQ_CMD_CMP_GE = 0xB9,
-	SSEQ_CMD_CMP_GT = 0xBA,
-	SSEQ_CMD_CMP_LE = 0xBB,
-	SSEQ_CMD_CMP_LT = 0xBC,
-	SSEQ_CMD_CMP_NE = 0xBD,
-
-	SSEQ_CMD_MUTE = 0xD7 // Unsupported
+enum class SSEQCommand
+{
+	AllocateTrack = 0xFE, // Silently ignored
+	OpenTrack = 0x93,
+
+	Rest = 0x80,
+	Patch = 0x81,
+	Pan = 0xC0,
+	Volume = 0xC1,
+	MasterVolume = 0xC2,
+	Priority = 0xC6,
+	NoteWait = 0xC7,
+	Tie = 0xC8,
+	Expression = 0xD5,
+	Tempo = 0xE1,
+	End = 0xFF,
+
+	Goto = 0x94,
+	Call = 0x95,
+	Return = 0xFD,
+	LoopStart = 0xD4,
+	LoopEnd = 0xFC,
+
+	Transpose = 0xC3,
+	PitchBend = 0xC4,
+	PitchBendRange = 0xC5,
+
+	Attack = 0xD0,
+	Decay = 0xD1,
+	Sustain = 0xD2,
+	Release = 0xD3,
+
+	PortamentoKey = 0xC9,
+	PortamentoFlag = 0xCE,
+	PortamentoTime = 0xCF,
+	SweepPitch = 0xE3,
+
+	ModulationDepth = 0xCA,
+	ModulationSpeed = 0xCB,
+	ModulationType = 0xCC,
+	ModulationRange = 0xCD,
+	ModulationDelay = 0xE0,
+
+	Random = 0xA0,
+	PrintVariable = 0xD6,
+	If = 0xA2,
+	FromVariable = 0xA1,
+	SetVariable = 0xB0,
+	AddVariable = 0xB1,
+	SubtractVariable = 0xB2,
+	MultiplyVariable = 0xB3,
+	DivideVariable = 0xB4,
+	ShiftVariable = 0xB5,
+	RandomVariable = 0xB6,
+	CompareEqualTo = 0xB8,
+	CompareGreaterThanOrEqualTo = 0xB9,
+	CompareGreaterThan = 0xBA,
+	CompareLessThanOrEqualTo = 0xBB,
+	CompareLessThan = 0xBC,
+	CompareNotEqualTo = 0xBD,
+
+	Mute = 0xD7 // Unsupported
 };
 
-static const uint8_t VariableByteCount = 1 << 7;
-static const uint8_t ExtraByteOnNoteOrVarOrCmp = 1 << 6;
-
-static inline uint8_t SseqCommandByteCount(int cmd)
+static const std::uint8_t VariableByteCount = 1 << 7;
+static const std::uint8_t ExtraByteOnNoteOrVarOrCmp = 1 << 6;
+
+static inline std::uint8_t SseqCommandByteCount(int cmd)
 {
 	if (cmd < 0x80)
 		return 1 | VariableByteCount;
 	else
-		switch (cmd)
+		switch (static_cast<SSEQCommand>(cmd))
 		{
-			case SSEQ_CMD_REST:
-			case SSEQ_CMD_PATCH:
+			case SSEQCommand::Rest:
+			case SSEQCommand::Patch:
 				return VariableByteCount;
 
-			case SSEQ_CMD_PAN:
-			case SSEQ_CMD_VOL:
-			case SSEQ_CMD_MASTERVOL:
-			case SSEQ_CMD_PRIO:
-			case SSEQ_CMD_NOTEWAIT:
-			case SSEQ_CMD_TIE:
-			case SSEQ_CMD_EXPR:
-			case SSEQ_CMD_LOOPSTART:
-			case SSEQ_CMD_TRANSPOSE:
-			case SSEQ_CMD_PITCHBEND:
-			case SSEQ_CMD_PITCHBENDRANGE:
-			case SSEQ_CMD_ATTACK:
-			case SSEQ_CMD_DECAY:
-			case SSEQ_CMD_SUSTAIN:
-			case SSEQ_CMD_RELEASE:
-			case SSEQ_CMD_PORTAKEY:
-			case SSEQ_CMD_PORTAFLAG:
-			case SSEQ_CMD_PORTATIME:
-			case SSEQ_CMD_MODDEPTH:
-			case SSEQ_CMD_MODSPEED:
-			case SSEQ_CMD_MODTYPE:
-			case SSEQ_CMD_MODRANGE:
-			case SSEQ_CMD_PRINTVAR:
-			case SSEQ_CMD_MUTE:
+			case SSEQCommand::Pan:
+			case SSEQCommand::Volume:
+			case SSEQCommand::MasterVolume:
+			case SSEQCommand::Priority:
+			case SSEQCommand::NoteWait:
+			case SSEQCommand::Tie:
+			case SSEQCommand::Expression:
+			case SSEQCommand::LoopStart:
+			case SSEQCommand::Transpose:
+			case SSEQCommand::PitchBend:
+			case SSEQCommand::PitchBendRange:
+			case SSEQCommand::Attack:
+			case SSEQCommand::Decay:
+			case SSEQCommand::Sustain:
+			case SSEQCommand::Release:
+			case SSEQCommand::PortamentoKey:
+			case SSEQCommand::PortamentoFlag:
+			case SSEQCommand::PortamentoTime:
+			case SSEQCommand::ModulationDepth:
+			case SSEQCommand::ModulationSpeed:
+			case SSEQCommand::ModulationType:
+			case SSEQCommand::ModulationRange:
+			case SSEQCommand::PrintVariable:
+			case SSEQCommand::Mute:
 				return 1;
 
-			case SSEQ_CMD_ALLOCTRACK:
-			case SSEQ_CMD_TEMPO:
-			case SSEQ_CMD_SWEEPPITCH:
-			case SSEQ_CMD_MODDELAY:
+			case SSEQCommand::AllocateTrack:
+			case SSEQCommand::Tempo:
+			case SSEQCommand::SweepPitch:
+			case SSEQCommand::ModulationDelay:
 				return 2;
 
-			case SSEQ_CMD_GOTO:
-			case SSEQ_CMD_CALL:
-			case SSEQ_CMD_SETVAR:
-			case SSEQ_CMD_ADDVAR:
-			case SSEQ_CMD_SUBVAR:
-			case SSEQ_CMD_MULVAR:
-			case SSEQ_CMD_DIVVAR:
-			case SSEQ_CMD_SHIFTVAR:
-			case SSEQ_CMD_RANDVAR:
-			case SSEQ_CMD_CMP_EQ:
-			case SSEQ_CMD_CMP_GE:
-			case SSEQ_CMD_CMP_GT:
-			case SSEQ_CMD_CMP_LE:
-			case SSEQ_CMD_CMP_LT:
-			case SSEQ_CMD_CMP_NE:
+			case SSEQCommand::Goto:
+			case SSEQCommand::Call:
+			case SSEQCommand::SetVariable:
+			case SSEQCommand::AddVariable:
+			case SSEQCommand::SubtractVariable:
+			case SSEQCommand::MultiplyVariable:
+			case SSEQCommand::DivideVariable:
+			case SSEQCommand::ShiftVariable:
+			case SSEQCommand::RandomVariable:
+			case SSEQCommand::CompareEqualTo:
+			case SSEQCommand::CompareGreaterThanOrEqualTo:
+			case SSEQCommand::CompareGreaterThan:
+			case SSEQCommand::CompareLessThanOrEqualTo:
+			case SSEQCommand::CompareLessThan:
+			case SSEQCommand::CompareNotEqualTo:
 				return 3;
 
-			case SSEQ_CMD_OPENTRACK:
+			case SSEQCommand::OpenTrack:
 				return 4;
 
-			case SSEQ_CMD_FROMVAR:
+			case SSEQCommand::FromVariable:
 				return 1 | ExtraByteOnNoteOrVarOrCmp; // Technically 2 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed
 
-			case SSEQ_CMD_RANDOM:
+			case SSEQCommand::Random:
 				return 4 | ExtraByteOnNoteOrVarOrCmp; // Technically 5 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed
 
 			default:
@@ -410,19 +418,19 @@
 	return static_cast<std::uint16_t>(RandomU >> 16);
 }
 
-static auto varFuncSet = [](int16_t, int16_t value) { return value; };
-static auto varFuncAdd = [](int16_t var, int16_t value) -> int16_t { return var + value; };
-static auto varFuncSub = [](int16_t var, int16_t value) -> int16_t { return var - value; };
-static auto varFuncMul = [](int16_t var, int16_t value) -> int16_t { return var * value; };
-static auto varFuncDiv = [](int16_t var, int16_t value) -> int16_t { return var / value; };
-static auto varFuncShift = [](int16_t var, int16_t value) -> int16_t
+static auto varFuncSet = [](std::int16_t, std::int16_t value) { return value; };
+static auto varFuncAdd = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var + value; };
+static auto varFuncSub = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var - value; };
+static auto varFuncMul = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var * value; };
+static auto varFuncDiv = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var / value; };
+static auto varFuncShift = [](std::int16_t var, std::int16_t value) -> std::int16_t
 {
 	if (value < 0)
 		return var >> -value;
 	else
 		return var << value;
 };
-static auto varFuncRand = [](int16_t, int16_t value) -> int16_t
+static auto varFuncRand = [](std::int16_t, std::int16_t value) -> std::int16_t
 {
 	if (value < 0)
 		return -(CalcRandom() % (-value + 1));
@@ -430,51 +438,51 @@
 		return CalcRandom() % (value + 1);
 };
 
-static inline std::function<int16_t (int16_t, int16_t)> VarFunc(int cmd)
-{
-	switch (cmd)
-	{
-		case SSEQ_CMD_SETVAR:
+static inline std::function<std::int16_t (std::int16_t, std::int16_t)> VarFunc(int cmd)
+{
+	switch (static_cast<SSEQCommand>(cmd))
+	{
+		case SSEQCommand::SetVariable:
 			return varFuncSet;
-		case SSEQ_CMD_ADDVAR:
+		case SSEQCommand::AddVariable:
 			return varFuncAdd;
-		case SSEQ_CMD_SUBVAR:
+		case SSEQCommand::SubtractVariable:
 			return varFuncSub;
-		case SSEQ_CMD_MULVAR:
+		case SSEQCommand::MultiplyVariable:
 			return varFuncMul;
-		case SSEQ_CMD_DIVVAR:
+		case SSEQCommand::DivideVariable:
 			return varFuncDiv;
-		case SSEQ_CMD_SHIFTVAR:
+		case SSEQCommand::ShiftVariable:
 			return varFuncShift;
-		case SSEQ_CMD_RANDVAR:
+		case SSEQCommand::RandomVariable:
 			return varFuncRand;
 		default:
 			return nullptr;
 	}
 }
 
-static auto compareFuncEq = [](int16_t a, int16_t b) { return a == b; };
-static auto compareFuncGe = [](int16_t a, int16_t b) { return a >= b; };
-static auto compareFuncGt = [](int16_t a, int16_t b) { return a > b; };
-static auto compareFuncLe = [](int16_t a, int16_t b) { return a <= b; };
-static auto compareFuncLt = [](int16_t a, int16_t b) { return a < b; };
-static auto compareFuncNe = [](int16_t a, int16_t b) { return a != b; };
-
-static inline std::function<bool (int16_t, int16_t)> CompareFunc(int cmd)
-{
-	switch (cmd)
-	{
-		case SSEQ_CMD_CMP_EQ:
+static auto compareFuncEq = [](std::int16_t a, std::int16_t b) { return a == b; };
+static auto compareFuncGe = [](std::int16_t a, std::int16_t b) { return a >= b; };
+static auto compareFuncGt = [](std::int16_t a, std::int16_t b) { return a > b; };
+static auto compareFuncLe = [](std::int16_t a, std::int16_t b) { return a <= b; };
+static auto compareFuncLt = [](std::int16_t a, std::int16_t b) { return a < b; };
+static auto compareFuncNe = [](std::int16_t a, std::int16_t b) { return a != b; };
+
+static inline std::function<bool (std::int16_t, std::int16_t)> CompareFunc(int cmd)
+{
+	switch (static_cast<SSEQCommand>(cmd))
+	{
+		case SSEQCommand::CompareEqualTo:
 			return compareFuncEq;
-		case SSEQ_CMD_CMP_GE:
+		case SSEQCommand::CompareGreaterThanOrEqualTo:
 			return compareFuncGe;
-		case SSEQ_CMD_CMP_GT:
+		case SSEQCommand::CompareGreaterThan:
 			return compareFuncGt;
-		case SSEQ_CMD_CMP_LE:
+		case SSEQCommand::CompareLessThanOrEqualTo:
 			return compareFuncLe;
-		case SSEQ_CMD_CMP_LT:
+		case SSEQCommand::CompareLessThan:
 			return compareFuncLt;
-		case SSEQ_CMD_CMP_NE:
+		case SSEQCommand::CompareNotEqualTo:
 			return compareFuncNe;
 		default:
 			return nullptr;
@@ -485,10 +493,10 @@
 void Track::Run()
 {
 	// Indicate "heartbeat" for this track
-	this->updateFlags.set(TUF_LEN);
+	this->updateFlags.set(ToIntegral(TrackUpdateFlag::Length));
 
 	// Exit if the track has already ended
-	if (this->state[TS_END])
+	if (this->state[ToIntegral(TrackState::End)])
 		return;
 
 	if (this->wait)
@@ -513,9 +521,9 @@
 			int key = cmd + this->transpose;
 			int vel = this->overriding.val(pData, read8, true);
 			int len = this->overriding.val(pData, readvl);
-			if (this->state[TS_NOTEWAIT])
+			if (this->state[ToIntegral(TrackState::NoteWait)])
 				this->wait = len;
-			if (this->state[TS_TIEBIT])
+			if (this->state[ToIntegral(TrackState::TieBit)])
 				this->NoteOnTie(key, vel);
 			else
 				this->NoteOn(key, vel, len);
@@ -523,13 +531,13 @@
 		else
 		{
 			int value;
-			switch (cmd)
+			switch (static_cast<SSEQCommand>(cmd))
 			{
 				//-----------------------------------------------------------------
 				// Main commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_OPENTRACK:
+				case SSEQCommand::OpenTrack:
 				{
 					int tNum = read8(pData);
 					auto trackPos = &this->ply->sseq->data[read24(pData)];
@@ -542,91 +550,91 @@
 					break;
 				}
 
-				case SSEQ_CMD_REST:
+				case SSEQCommand::Rest:
 					this->wait = this->overriding.val(pData, readvl);
 					break;
 
-				case SSEQ_CMD_PATCH:
+				case SSEQCommand::Patch:
 					this->patch = this->overriding.val(pData, readvl);
 					break;
 
-				case SSEQ_CMD_GOTO:
+				case SSEQCommand::Goto:
 					*pData = &this->ply->sseq->data[read24(pData)];
 					break;
 
-				case SSEQ_CMD_CALL:
+				case SSEQCommand::Call:
 					value = read24(pData);
 					if (this->stackPos < FSS_TRACKSTACKSIZE)
 					{
-						const uint8_t *dest = &this->ply->sseq->data[value];
-						this->stack[this->stackPos++] = StackValue(STACKTYPE_CALL, *pData);
+						const std::uint8_t *dest = &this->ply->sseq->data[value];
+						this->stack[this->stackPos++] = StackValue(StackType::Call, *pData);
 						*pData = dest;
 					}
 					break;
 
-				case SSEQ_CMD_RET:
-					if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_CALL)
+				case SSEQCommand::Return:
+					if (this->stackPos && this->stack[this->stackPos - 1].type == StackType::Call)
 						*pData = this->stack[--this->stackPos].dest;
 					break;
 
-				case SSEQ_CMD_PAN:
+				case SSEQCommand::Pan:
 					this->pan = this->overriding.val(pData, read8) - 64;
-					this->updateFlags.set(TUF_PAN);
-					break;
-
-				case SSEQ_CMD_VOL:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Pan));
+					break;
+
+				case SSEQCommand::Volume:
 					this->vol = this->overriding.val(pData, read8);
-					this->updateFlags.set(TUF_VOL);
-					break;
-
-				case SSEQ_CMD_MASTERVOL:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume));
+					break;
+
+				case SSEQCommand::MasterVolume:
 					this->ply->masterVol = Cnv_Sust(this->overriding.val(pData, read8));
-					for (uint8_t i = 0; i < this->ply->nTracks; ++i)
-						this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(TUF_VOL);
-					break;
-
-				case SSEQ_CMD_PRIO:
+					for (std::uint8_t i = 0; i < this->ply->nTracks; ++i)
+						this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(ToIntegral(TrackUpdateFlag::Volume));
+					break;
+
+				case SSEQCommand::Priority:
 					this->prio = this->ply->prio + read8(pData);
 					// Update here?
 					break;
 
-				case SSEQ_CMD_NOTEWAIT:
-					this->state.set(TS_NOTEWAIT, !!read8(pData));
-					break;
-
-				case SSEQ_CMD_TIE:
-					this->state.set(TS_TIEBIT, !!read8(pData));
+				case SSEQCommand::NoteWait:
+					this->state.set(ToIntegral(TrackState::NoteWait), !!read8(pData));
+					break;
+
+				case SSEQCommand::Tie:
+					this->state.set(ToIntegral(TrackState::TieBit), !!read8(pData));
 					this->ReleaseAllNotes();
 					break;
 
-				case SSEQ_CMD_EXPR:
+				case SSEQCommand::Expression:
 					this->expr = this->overriding.val(pData, read8);
-					this->updateFlags.set(TUF_VOL);
-					break;
-
-				case SSEQ_CMD_TEMPO:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume));
+					break;
+
+				case SSEQCommand::Tempo:
 					this->ply->tempo = read16(pData);
 					break;
 
-				case SSEQ_CMD_END:
-					this->state.set(TS_END);
+				case SSEQCommand::End:
+					this->state.set(ToIntegral(TrackState::End));
 					return;
 
-				case SSEQ_CMD_LOOPSTART:
+				case SSEQCommand::LoopStart:
 					value = this->overriding.val(pData, read8);
 					if (this->stackPos < FSS_TRACKSTACKSIZE)
 					{
 						this->loopCount[this->stackPos] = value;
-						this->stack[this->stackPos++] = StackValue(STACKTYPE_LOOP, *pData);
+						this->stack[this->stackPos++] = StackValue(StackType::Loop, *pData);
 					}
 					break;
 
-				case SSEQ_CMD_LOOPEND:
-					if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_LOOP)
+				case SSEQCommand::LoopEnd:
+					if (this->stackPos && this->stack[this->stackPos - 1].type == StackType::Loop)
 					{
-						const uint8_t *rPos = this->stack[this->stackPos - 1].dest;
-						uint8_t &nR = this->loopCount[this->stackPos - 1];
-						uint8_t prevR = nR;
+						const std::uint8_t *rPos = this->stack[this->stackPos - 1].dest;
+						std::uint8_t &nR = this->loopCount[this->stackPos - 1];
+						std::uint8_t prevR = nR;
 						if (!prevR || --nR)
 							*pData = rPos;
 						else
@@ -638,37 +646,37 @@
 				// Tuning commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_TRANSPOSE:
+				case SSEQCommand::Transpose:
 					this->transpose = this->overriding.val(pData, read8);
 					break;
 
-				case SSEQ_CMD_PITCHBEND:
+				case SSEQCommand::PitchBend:
 					this->pitchBend = this->overriding.val(pData, read8);
-					this->updateFlags.set(TUF_TIMER);
-					break;
-
-				case SSEQ_CMD_PITCHBENDRANGE:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Timer));
+					break;
+
+				case SSEQCommand::PitchBendRange:
 					this->pitchBendRange = read8(pData);
-					this->updateFlags.set(TUF_TIMER);
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Timer));
 					break;
 
 				//-----------------------------------------------------------------
 				// Envelope-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_ATTACK:
+				case SSEQCommand::Attack:
 					this->a = this->overriding.val(pData, read8);
 					break;
 
-				case SSEQ_CMD_DECAY:
+				case SSEQCommand::Decay:
 					this->d = this->overriding.val(pData, read8);
 					break;
 
-				case SSEQ_CMD_SUSTAIN:
+				case SSEQCommand::Sustain:
 					this->s = this->overriding.val(pData, read8);
 					break;
 
-				case SSEQ_CMD_RELEASE:
+				case SSEQCommand::Release:
 					this->r = this->overriding.val(pData, read8);
 					break;
 
@@ -676,26 +684,26 @@
 				// Portamento-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_PORTAKEY:
+				case SSEQCommand::PortamentoKey:
 					this->portaKey = read8(pData) + this->transpose;
-					this->state.set(TS_PORTABIT);
+					this->state.set(ToIntegral(TrackState::PortamentoBit));
 					// Update here?
 					break;
 
-				case SSEQ_CMD_PORTAFLAG:
-					this->state.set(TS_PORTABIT, !!read8(pData));
+				case SSEQCommand::PortamentoFlag:
+					this->state.set(ToIntegral(TrackState::PortamentoBit), !!read8(pData));
 					// Update here?
 					break;
 
-				case SSEQ_CMD_PORTATIME:
+				case SSEQCommand::PortamentoTime:
 					this->portaTime = this->overriding.val(pData, read8);
-					this->state.set(TS_PORTABIT);
+					this->state.set(ToIntegral(TrackState::PortamentoBit));
 					// Update here?
 					break;
 
-				case SSEQ_CMD_SWEEPPITCH:
+				case SSEQCommand::SweepPitch:
 					this->sweepPitch = this->overriding.val(pData, read16);
-					this->state.set(TS_PORTABIT);
+					this->state.set(ToIntegral(TrackState::PortamentoBit));
 					// Update here?
 					break;
 
@@ -703,43 +711,43 @@
 				// Modulation-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_MODDEPTH:
+				case SSEQCommand::ModulationDepth:
 					this->modDepth = this->overriding.val(pData, read8);
-					this->updateFlags.set(TUF_MOD);
-					break;
-
-				case SSEQ_CMD_MODSPEED:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation));
+					break;
+
+				case SSEQCommand::ModulationSpeed:
 					this->modSpeed = this->overriding.val(pData, read8);
-					this->updateFlags.set(TUF_MOD);
-					break;
-
-				case SSEQ_CMD_MODTYPE:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation));
+					break;
+
+				case SSEQCommand::ModulationType:
 					this->modType = read8(pData);
-					this->updateFlags.set(TUF_MOD);
-					break;
-
-				case SSEQ_CMD_MODRANGE:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation));
+					break;
+
+				case SSEQCommand::ModulationRange:
 					this->modRange = read8(pData);
-					this->updateFlags.set(TUF_MOD);
-					break;
-
-				case SSEQ_CMD_MODDELAY:
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation));
+					break;
+
+				case SSEQCommand::ModulationDelay:
 					this->modDelay = this->overriding.val(pData, read16);
-					this->updateFlags.set(TUF_MOD);
+					this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation));
 					break;
 
 				//-----------------------------------------------------------------
 				// Randomness-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_RANDOM:
+				case SSEQCommand::Random:
 				{
 					this->overriding() = true;
 					this->overriding.cmd = read8(pData);
-					if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80)
+					if ((this->overriding.cmd >= ToIntegral(SSEQCommand::SetVariable) && this->overriding.cmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || this->overriding.cmd < 0x80)
 						this->overriding.extraValue = read8(pData);
-					int16_t minVal = read16(pData);
-					int16_t maxVal = read16(pData);
+					std::int16_t minVal = read16(pData);
+					std::int16_t maxVal = read16(pData);
 					this->overriding.value = (CalcRandom() % (maxVal - minVal + 1)) + minVal;
 					break;
 				}
@@ -748,25 +756,25 @@
 				// Variable-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_FROMVAR:
+				case SSEQCommand::FromVariable:
 					this->overriding() = true;
 					this->overriding.cmd = read8(pData);
-					if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80)
+					if ((this->overriding.cmd >= ToIntegral(SSEQCommand::SetVariable) && this->overriding.cmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || this->overriding.cmd < 0x80)
 						this->overriding.extraValue = read8(pData);
 					this->overriding.value = this->ply->variables[read8(pData)];
 					break;
 
-				case SSEQ_CMD_SETVAR:
-				case SSEQ_CMD_ADDVAR:
-				case SSEQ_CMD_SUBVAR:
-				case SSEQ_CMD_MULVAR:
-				case SSEQ_CMD_DIVVAR:
-				case SSEQ_CMD_SHIFTVAR:
-				case SSEQ_CMD_RANDVAR:
+				case SSEQCommand::SetVariable:
+				case SSEQCommand::AddVariable:
+				case SSEQCommand::SubtractVariable:
+				case SSEQCommand::MultiplyVariable:
+				case SSEQCommand::DivideVariable:
+				case SSEQCommand::ShiftVariable:
+				case SSEQCommand::RandomVariable:
 				{
-					int8_t varNo = this->overriding.val(pData, read8, true);
+					std::int8_t varNo = this->overriding.val(pData, read8, true);
 					value = this->overriding.val(pData, read16);
-					if (cmd == SSEQ_CMD_DIVVAR && !value) // Division by 0, skip it to prevent crashing
+					if (cmd == ToIntegral(SSEQCommand::DivideVariable) && !value) // Division by 0, skip it to prevent crashing
 						break;
 					this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], value);
 					break;
@@ -776,31 +784,31 @@
 				// Conditional-related commands
 				//-----------------------------------------------------------------
 
-				case SSEQ_CMD_CMP_EQ:
-				case SSEQ_CMD_CMP_GE:
-				case SSEQ_CMD_CMP_GT:
-				case SSEQ_CMD_CMP_LE:
-				case SSEQ_CMD_CMP_LT:
-				case SSEQ_CMD_CMP_NE:
+				case SSEQCommand::CompareEqualTo:
+				case SSEQCommand::CompareGreaterThanOrEqualTo:
+				case SSEQCommand::CompareGreaterThan:
+				case SSEQCommand::CompareLessThanOrEqualTo:
+				case SSEQCommand::CompareLessThan:
+				case SSEQCommand::CompareNotEqualTo:
 				{
-					int8_t varNo = this->overriding.val(pData, read8, true);
+					std::int8_t varNo = this->overriding.val(pData, read8, true);
 					value = this->overriding.val(pData, read16);
 					this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], value);
 					break;
 				}
 
-				case SSEQ_CMD_IF:
+				case SSEQCommand::If:
 					if (!this->lastComparisonResult)
 					{
 						int nextCmd = read8(pData);
-						uint8_t cmdBytes = SseqCommandByteCount(nextCmd);
+						std::uint8_t cmdBytes = SseqCommandByteCount(nextCmd);
 						bool variableBytes = !!(cmdBytes & VariableByteCount);
 						bool extraByte = !!(cmdBytes & ExtraByteOnNoteOrVarOrCmp);
 						cmdBytes &= ~(VariableByteCount | ExtraByteOnNoteOrVarOrCmp);
 						if (extraByte)
 						{
 							int extraCmd = read8(pData);
-							if ((extraCmd >= SSEQ_CMD_SETVAR && extraCmd <= SSEQ_CMD_CMP_NE) || extraCmd < 0x80)
+							if ((extraCmd >= ToIntegral(SSEQCommand::SetVariable) && extraCmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || extraCmd < 0x80)
 								++cmdBytes;
 						}
 						*pData += cmdBytes;
@@ -814,7 +822,7 @@
 			}
 		}
 
-		if (cmd != SSEQ_CMD_RANDOM && cmd != SSEQ_CMD_FROMVAR)
+		if (cmd != ToIntegral(SSEQCommand::Random) && cmd != ToIntegral(SSEQCommand::FromVariable))
 			this->overriding() = false;
 	}
 }

--- a/src/in_ncsf/SSEQPlayer/Track.h
+++ b/src/in_ncsf/SSEQPlayer/Track.h
@@ -9,25 +9,27 @@
 
 #pragma once
 
+#include <bitset>
 #include <functional>
-#include <bitset>
+#include <cstdint>
+#include "common.h"
 #include "consts.h"
 
 struct Player;
 
-enum StackType
+enum class StackType
 {
-	STACKTYPE_CALL,
-	STACKTYPE_LOOP
+	Call,
+	Loop
 };
 
 struct StackValue
 {
 	StackType type;
-	const uint8_t *dest;
+	const std::uint8_t *dest;
 
-	StackValue() : type(STACKTYPE_CALL), dest(nullptr) { }
-	StackValue(StackType newType, const uint8_t *newDest) : type(newType), dest(newDest) { }
+	StackValue() : type(StackType::Call), dest(nullptr) { }
+	StackValue(StackType newType, const std::uint8_t *newDest) : type(newType), dest(newDest) { }
 };
 
 struct Override
@@ -40,7 +42,7 @@
 	Override() : overriding(false), cmd(0), value(0), extraValue(0) { }
 	bool operator()() const { return this->overriding; }
 	bool &operator()() { return this->overriding; }
-	int val(const uint8_t **pData, std::function<int (const uint8_t **)> reader, bool returnExtra = false)
+	int val(const std::uint8_t **pData, std::function<int (const std::uint8_t **)> reader, bool returnExtra = false)
 	{
 		if (this->overriding)
 			return returnExtra ? this->extraValue : this->value;
@@ -51,40 +53,40 @@
 
 struct Track
 {
-	int8_t trackId;
+	std::int8_t trackId;
 
-	std::bitset<TS_BITS> state;
-	uint8_t num, prio;
+	std::bitset<ToIntegral(TrackState::Bits)> state;
+	std::uint8_t num, prio;
 	Player *ply;
 
-	const uint8_t *startPos;
-	const uint8_t *pos;
+	const std::uint8_t *startPos;
+	const std::uint8_t *pos;
 	StackValue stack[FSS_TRACKSTACKSIZE];
-	uint8_t stackPos;
-	uint8_t loopCount[FSS_TRACKSTACKSIZE];
+	std::uint8_t stackPos;
+	std::uint8_t loopCount[FSS_TRACKSTACKSIZE];
 	Override overriding;
 	bool lastComparisonResult;
 
 	int wait;
-	uint16_t patch;
-	uint8_t portaKey, portaTime;
-	int16_t sweepPitch;
-	uint8_t vol, expr;
-	int8_t pan; // -64..63
-	uint8_t pitchBendRange;
-	int8_t pitchBend;
-	int8_t transpose;
+	std::uint16_t patch;
+	std::uint8_t portaKey, portaTime;
+	std::int16_t sweepPitch;
+	std::uint8_t vol, expr;
+	std::int8_t pan; // -64..63
+	std::uint8_t pitchBendRange;
+	std::int8_t pitchBend;
+	std::int8_t transpose;
 
-	uint8_t a, d, s, r;
+	std::uint8_t a, d, s, r;
 
-	uint8_t modType, modSpeed, modDepth, modRange;
-	uint16_t modDelay;
+	std::uint8_t modType, modSpeed, modDepth, modRange;
+	std::uint16_t modDelay;
 
-	std::bitset<TUF_BITS> updateFlags;
+	std::bitset<ToIntegral(TrackUpdateFlag::Bits)> updateFlags;
 
 	Track();
 
-	void Init(uint8_t handle, Player *ply, const uint8_t *pos, int n);
+	void Init(std::uint8_t handle, Player *ply, const std::uint8_t *pos, int n);
 	void Zero();
 	void ClearState();
 	void Free();

--- a/src/in_ncsf/SSEQPlayer/common.h
+++ b/src/in_ncsf/SSEQPlayer/common.h
@@ -9,9 +9,12 @@
 
 #pragma once
 
+#include <algorithm>
 #include <string>
+#include <type_traits>
 #include <vector>
 #include <cstring>
+#include <cstddef>
 #include <cstdint>
 
 /*
@@ -19,8 +22,8 @@
  */
 struct PseudoFile
 {
-	std::vector<uint8_t> *data;
-	uint32_t pos;
+	std::vector<std::uint8_t> *data;
+	std::uint32_t pos;
 
 	PseudoFile() : data(nullptr), pos(0)
 	{
@@ -29,18 +32,18 @@
 	template<typename T> T ReadLE()
 	{
 		T finalVal = 0;
-		for (size_t i = 0; i < sizeof(T); ++i)
+		for (std::size_t i = 0; i < sizeof(T); ++i)
 			finalVal |= (*this->data)[this->pos++] << (i * 8);
 		return finalVal;
 	}
 
-	template<typename T, size_t N> void ReadLE(T (&arr)[N])
-	{
-		for (size_t i = 0; i < N; ++i)
+	template<typename T, std::size_t N> void ReadLE(T (&arr)[N])
+	{
+		for (std::size_t i = 0; i < N; ++i)
 			arr[i] = this->ReadLE<T>();
 	}
 
-	template<size_t N> void ReadLE(uint8_t arr[N])
+	template<std::size_t N> void ReadLE(std::uint8_t arr[N])
 	{
 		std::copy_n(&(*this->data)[this->pos], N, &arr[0]);
 		this->pos += N;
@@ -48,11 +51,11 @@
 
 	template<typename T> void ReadLE(std::vector<T> &arr)
 	{
-		for (size_t i = 0, len = arr.size(); i < len; ++i)
+		for (std::size_t i = 0, len = arr.size(); i < len; ++i)
 			arr[i] = this->ReadLE<T>();
 	}
 
-	void ReadLE(std::vector<uint8_t> &arr)
+	void ReadLE(std::vector<std::uint8_t> &arr)
 	{
 		std::copy_n(&(*this->data)[this->pos], arr.size(), &arr[0]);
 		this->pos += arr.size();
@@ -64,7 +67,7 @@
 		std::string str;
 		do
 		{
-			chr = static_cast<char>(this->ReadLE<uint8_t>());
+			chr = static_cast<char>(this->ReadLE<std::uint8_t>());
 			if (chr)
 				str += chr;
 		} while (chr);
@@ -80,10 +83,10 @@
  * as little-endian formating.
  */
 
-template<typename T> inline T ReadLE(const uint8_t *arr)
+template<typename T> inline T ReadLE(const std::uint8_t *arr)
 {
 	T finalVal = 0;
-	for (size_t i = 0; i < sizeof(T); ++i)
+	for (std::size_t i = 0; i < sizeof(T); ++i)
 		finalVal |= arr[i] << (i * 8);
 	return finalVal;
 }
@@ -97,10 +100,10 @@
 template<typename T> inline std::string NumToHexString(const T &num)
 {
 	std::string hex;
-	uint8_t len = sizeof(T) * 2;
-	for (uint8_t i = 0; i < len; ++i)
-	{
-		uint8_t tmp = (num >> (i * 4)) & 0xF;
+	std::uint8_t len = sizeof(T) * 2;
+	for (std::uint8_t i = 0; i < len; ++i)
+	{
+		std::uint8_t tmp = (num >> (i * 4)) & 0xF;
 		hex = static_cast<char>(tmp < 10 ? tmp + '0' : tmp - 10 + 'a') + hex;
 	}
 	return "0x" + hex;
@@ -120,7 +123,13 @@
 inline constexpr int REC_PLAYER2 = 6;
 inline constexpr int REC_STRM = 7;
 
-template<size_t N> inline bool VerifyHeader(int8_t (&arr)[N], const std::string &header)
+// Comes from https://stackoverflow.com/a/14589519
+template<typename T> inline constexpr auto ToIntegral(const T &e) -> typename std::underlying_type_t<T>
+{
+	return static_cast<std::underlying_type_t<T>>(e);
+}
+
+template<std::size_t N> inline bool VerifyHeader(std::int8_t (&arr)[N], const std::string &header)
 {
 	std::string arrHeader = std::string(&arr[0], &arr[N]);
 	return arrHeader == header;
@@ -131,7 +140,7 @@
  */
 inline int Cnv_Attack(int attk)
 {
-	static const uint8_t lut[] =
+	static const std::uint8_t lut[] =
 	{
 		0x00, 0x01, 0x05, 0x0E, 0x1A, 0x26, 0x33, 0x3F, 0x49, 0x54,
 		0x5C, 0x64, 0x6D, 0x74, 0x7B, 0x7F, 0x84, 0x89, 0x8F
@@ -158,7 +167,7 @@
 
 inline int Cnv_Scale(int scale)
 {
-	static const int16_t lut[] =
+	static const std::int16_t lut[] =
 	{
 		-32768, -421, -361, -325, -300, -281, -265, -252,
 		-240, -230, -221, -212, -205, -198, -192, -186,
@@ -185,7 +194,7 @@
 
 inline int Cnv_Sust(int sust)
 {
-	static const int16_t lut[] =
+	static const std::int16_t lut[] =
 	{
 		-32768, -722, -721, -651, -601, -562, -530, -503,
 		-480, -460, -442, -425, -410, -396, -383, -371,
@@ -212,12 +221,12 @@
 
 inline int Cnv_Sine(int arg)
 {
-	static const int8_t lut[] =
+	static const std::int8_t lut[] =
 	{
 		0, 6, 12, 19, 25, 31, 37, 43, 49, 54, 60, 65, 71, 76, 81, 85, 90, 94,
 		98, 102, 106, 109, 112, 115, 117, 120, 122, 123, 125, 126, 126, 127, 127
 	};
-	static const int lut_size = sizeof(lut) / sizeof(int8_t);
+	static const int lut_size = sizeof(lut) / sizeof(std::int8_t);
 
 	if (arg < lut_size)
 		return lut[arg];
@@ -229,7 +238,7 @@
 	return -lut[4 * lut_size - arg];
 }
 
-inline int read8(const uint8_t **ppData)
+inline int read8(const std::uint8_t **ppData)
 {
 	auto pData = *ppData;
 	int x = *pData;
@@ -237,14 +246,14 @@
 	return x;
 }
 
-inline int read16(const uint8_t **ppData)
+inline int read16(const std::uint8_t **ppData)
 {
 	int x = read8(ppData);
 	x |= read8(ppData) << 8;
 	return x;
 }
 
-inline int read24(const uint8_t **ppData)
+inline int read24(const std::uint8_t **ppData)
 {
 	int x = read8(ppData);
 	x |= read8(ppData) << 8;
@@ -252,7 +261,7 @@
 	return x;
 }
 
-inline int readvl(const uint8_t **ppData)
+inline int readvl(const std::uint8_t **ppData)
 {
 	int x = 0;
 	for (;;)

--- a/src/in_ncsf/SSEQPlayer/consts.h
+++ b/src/in_ncsf/SSEQPlayer/consts.h
@@ -14,47 +14,82 @@
 
 #include <cstdint>
 
-const uint32_t ARM7_CLOCK = 33513982;
-const double SecondsPerClockCycle = 64.0 * 2728.0 / ARM7_CLOCK;
+inline constexpr std::uint32_t ARM7_CLOCK = 33513982;
+inline constexpr double SecondsPerClockCycle = 64.0 * 2728.0 / ARM7_CLOCK;
 
-inline uint32_t BIT(uint32_t n) { return 1 << n; }
+inline std::uint32_t BIT(std::uint32_t n) { return 1 << n; }
 
-enum { TS_ALLOCBIT, TS_NOTEWAIT, TS_PORTABIT, TS_TIEBIT, TS_END, TS_BITS };
+enum class TrackState
+{
+	AllocateBit,
+	NoteWait,
+	PortamentoBit,
+	TieBit,
+	End,
+	Bits
+};
 
-enum { TUF_VOL, TUF_PAN, TUF_TIMER, TUF_MOD, TUF_LEN, TUF_BITS };
+enum class TrackUpdateFlag
+{
+	Volume,
+	Pan,
+	Timer,
+	Modulation,
+	Length,
+	Bits
+};
 
-enum { CS_NONE, CS_START, CS_ATTACK, CS_DECAY, CS_SUSTAIN, CS_RELEASE };
+enum class ChannelState
+{
+	None,
+	Start,
+	Attack,
+	Decay,
+	Sustain,
+	Release
+};
 
-enum { CF_UPDVOL, CF_UPDPAN, CF_UPDTMR, CF_BITS };
+enum class ChannelFlag
+{
+	UpdateVolume,
+	UpdatePan,
+	UpdateTimer,
+	Bits
+};
 
-enum { TYPE_PCM, TYPE_PSG, TYPE_NOISE };
+enum class ChannelAllocateType
+{
+	PCM,
+	PSG,
+	Noise
+};
 
-const int FSS_TRACKCOUNT = 16;
-const int FSS_MAXTRACKS = 32;
-const int FSS_TRACKSTACKSIZE = 3;
-const int AMPL_K = 723;
-const int AMPL_MIN = -AMPL_K;
-const int AMPL_THRESHOLD = AMPL_MIN * 128;
+inline constexpr int FSS_TRACKCOUNT = 16;
+inline constexpr int FSS_MAXTRACKS = 32;
+inline constexpr int FSS_TRACKSTACKSIZE = 3;
+inline constexpr int AMPL_K = 723;
+inline constexpr int AMPL_MIN = -AMPL_K;
+inline constexpr int AMPL_THRESHOLD = AMPL_MIN * 128;
 
 inline int SOUND_FREQ(int n) { return -0x1000000 / n; }
 
-inline uint32_t SOUND_VOL(int n) { return n; }
-inline uint32_t SOUND_VOLDIV(int n) { return n << 8; }
-inline uint32_t SOUND_PAN(int n) { return n << 16; }
-inline uint32_t SOUND_DUTY(int n) { return n << 24; }
-const uint32_t SOUND_REPEAT = BIT(27);
-const uint32_t SOUND_ONE_SHOT = BIT(28);
-inline uint32_t SOUND_LOOP(bool a) { return a ? SOUND_REPEAT : SOUND_ONE_SHOT; }
-const uint32_t SOUND_FORMAT_PSG = 3 << 29;
-inline uint32_t SOUND_FORMAT(int n) { return n << 29; }
-const uint32_t SCHANNEL_ENABLE = BIT(31);
+inline std::uint32_t SOUND_VOL(int n) { return n; }
+inline std::uint32_t SOUND_VOLDIV(int n) { return n << 8; }
+inline std::uint32_t SOUND_PAN(int n) { return n << 16; }
+inline std::uint32_t SOUND_DUTY(int n) { return n << 24; }
+inline const std::uint32_t SOUND_REPEAT = BIT(27);
+inline const std::uint32_t SOUND_ONE_SHOT = BIT(28);
+inline std::uint32_t SOUND_LOOP(bool a) { return a ? SOUND_REPEAT : SOUND_ONE_SHOT; }
+inline constexpr std::uint32_t SOUND_FORMAT_PSG = 3 << 29;
+inline std::uint32_t SOUND_FORMAT(int n) { return n << 29; }
+inline const std::uint32_t SCHANNEL_ENABLE = BIT(31);
 
-enum Interpolation
+enum class Interpolation
 {
-	INTERPOLATION_NONE,
-	INTERPOLATION_LINEAR,
-	INTERPOLATION_4POINTLEGRANGE,
-	INTERPOLATION_6POINTLEGRANGE,
-	INTERPOLATION_SINC
+	None,
+	Linear,
+	FourPointLegrange,
+	SixPointLegrange,
+	Sinc
 };
 

--- a/src/in_ncsf/XSFConfig_NCSF.cpp
+++ b/src/in_ncsf/XSFConfig_NCSF.cpp
@@ -5,9 +5,19 @@
  * Partially based on the vio*sf framework
  */
 
+#include <bitset>
+#include <sstream>
+#include <string>
+#include <cstddef>
+#include "windowsh_wrapper.h"
+#include <windowsx.h>
 #include "XSFConfig_NCSF.h"
+#include "XSFPlayer_NCSF.h"
 #include "convert.h"
 #ifdef _DEBUG
+# include <cstdint>
+# include "SSEQPlayer/common.h"
+# include "SSEQPlayer/consts.h"
 # include "resource.h"
 # include <CommCtrl.h>
 #endif
@@ -62,11 +72,11 @@
 
 void XSFConfig_NCSF::GenerateSpecificDialogs()
 {
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(110, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idInterpolation).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(110, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idInterpolation).
 		IsDropDownList().WithTabStop());
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).
 		WithBorder().WithVerticalScrollbar().WithMultipleSelect().WithTabStop());
 }
 
@@ -83,7 +93,7 @@
 			SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"16-point Sinc (Nuttall 3-term Window)"));
 			SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, this->interpolation, 0);
 			// Mutes
-			for (int x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
+			for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
 			{
 				SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((L"SPU " + std::to_wstring(x + 1)).c_str()));
 				SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, this->mutes[x], x);
@@ -100,14 +110,14 @@
 {
 	SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, XSFConfig_NCSF::initInterpolation, 0);
 	auto tmpMutes = std::bitset<16>(XSFConfig_NCSF::initMutes);
-	for (int x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x)
+	for (std::size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x)
 		SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, tmpMutes[x], x);
 }
 
 void XSFConfig_NCSF::SaveSpecificConfigDialog(HWND hwndDlg)
 {
 	this->interpolation = static_cast<unsigned>(SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_GETCURSEL, 0, 0));
-	for (int x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
+	for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
 		this->mutes[x] = !!SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_GETSEL, x, 0);
 }
 
@@ -235,7 +245,7 @@
 	}
 }
 
-static inline int32_t muldiv7(int32_t val, uint8_t mul)
+static inline std::int32_t muldiv7(std::int32_t val, std::uint8_t mul)
 {
 	return mul == 127 ? val : ((val * mul) >> 7);
 }
@@ -245,17 +255,17 @@
 	auto player = this->soundViewData->player;
 	auto hDlg = this->soundViewData->hDlg;
 	std::wstring buf;
-	for (size_t chanId = 0; chanId < 16; ++chanId)
+	for (std::size_t chanId = 0; chanId < 16; ++chanId)
 	{
 		const auto &chn = player->GetChannel(chanId);
 
-		if (chn.state > CS_START)
+		if (chn.state > ChannelState::Start)
 		{
 			ProgressSetPosImmediate(hDlg, IDC_SOUND0PANBAR + chanId, muldiv7(128, chn.reg.panning));
-			uint8_t datashift = chn.reg.volumeDiv;
+			std::uint8_t datashift = chn.reg.volumeDiv;
 			if (datashift == 3)
 				datashift = 4;
-			int32_t vol = muldiv7(128, chn.reg.volumeMul) >> datashift;
+			std::int32_t vol = muldiv7(128, chn.reg.volumeMul) >> datashift;
 			ProgressSetPosImmediate(hDlg, IDC_SOUND0VOLBAR + chanId, vol);
 
 			if (this->soundViewData->volModeAlternative)
@@ -298,7 +308,7 @@
 			}
 
 			static const std::wstring states[] = { L"NONE", L"START", L"ATTACK", L"DECAY", L"SUSTAIN", L"RELEASE" };
-			SetDlgItemTextW(hDlg, IDC_SOUND0STATE + chanId, states[chn.state].c_str());
+			SetDlgItemTextW(hDlg, IDC_SOUND0STATE + chanId, states[ToIntegral(chn.state)].c_str());
 
 			SetDlgItemTextW(hDlg, IDC_SOUND0PNT + chanId, (L"samp #" + std::to_wstring(chn.reg.loopStart)).c_str());
 
@@ -310,9 +320,9 @@
 			buf += tmpBuf + L" Hz)";
 			SetDlgItemTextW(hDlg, IDC_SOUND0TMR + chanId, buf.c_str());
 
-			SetDlgItemTextW(hDlg, IDC_SOUND0POSLEN + chanId, (L"samp #" + std::to_wstring(static_cast<uint32_t>(chn.reg.samplePosition)) + L" / " + std::to_wstring(chn.reg.totalLength)).c_str());
+			SetDlgItemTextW(hDlg, IDC_SOUND0POSLEN + chanId, (L"samp #" + std::to_wstring(static_cast<std::uint32_t>(chn.reg.samplePosition)) + L" / " + std::to_wstring(chn.reg.totalLength)).c_str());
 		}
-		else if (this->soundViewData->channelLastStates[chanId] != CS_NONE)
+		else if (this->soundViewData->channelLastStates[chanId] != ChannelState::None)
 		{
 			ProgressSetPosImmediate(hDlg, IDC_SOUND0PANBAR + chanId, 0);
 			ProgressSetPosImmediate(hDlg, IDC_SOUND0VOLBAR + chanId, 0);

--- a/src/in_ncsf/XSFConfig_NCSF.h
+++ b/src/in_ncsf/XSFConfig_NCSF.h
@@ -8,26 +8,32 @@
 #pragma once
 
 #include <bitset>
-#include <memory>
+#include <string>
+#ifdef _DEBUG
+# include <algorithm>
+# include <memory>
+# include <cstdint>
+# include "SSEQPlayer/consts.h"
+#endif
+#include "windowsh_wrapper.h"
 #include "XSFConfig.h"
-#include "XSFPlayer_NCSF.h"
-#include "windowsh_wrapper.h"
 
 class XSFConfig_NCSF;
+class XSFPlayer_NCSF;
 
 #ifdef _DEBUG
 struct SoundViewData
 {
 	XSFConfig_NCSF *config;
 	XSFPlayer_NCSF *player;
-	uint8_t channelLastStates[16];
+	ChannelState channelLastStates[16];
 	HWND hDlg;
 
 	bool volModeAlternative;
 
 	SoundViewData() : config(nullptr), player(nullptr), hDlg(nullptr), volModeAlternative(false)
 	{
-		std::fill_n(&this->channelLastStates[0], sizeof(this->channelLastStates), CS_START);
+		std::fill_n(&this->channelLastStates[0], sizeof(this->channelLastStates), ChannelState::Start);
 	}
 };
 #endif

--- a/src/in_ncsf/XSFPlayer_NCSF.cpp
+++ b/src/in_ncsf/XSFPlayer_NCSF.cpp
@@ -8,17 +8,22 @@
  * https://github.com/fincs/FSS
  */
 
+#include <algorithm>
+#include <bitset>
 #include <filesystem>
 #include <memory>
-#include <cstdlib>
-#include <ctime>
+#include <string>
+#include <vector>
+#include <cstddef>
+#include <cstdint>
 #include <zlib.h>
-#include "convert.h"
+#include "XSFCommon.h"
+#include "XSFConfig_NCSF.h"
 #include "XSFPlayer_NCSF.h"
-#include "XSFConfig_NCSF.h"
-#include "XSFCommon.h"
 #include "SSEQPlayer/SDAT.h"
 #include "SSEQPlayer/Player.h"
+#include "SSEQPlayer/common.h"
+#include "SSEQPlayer/consts.h"
 
 const char *XSFPlayer::WinampDescription = "NCSF Decoder";
 const char *XSFPlayer::WinampExts = "ncsf;minincsf\0DS Nitro Composer Sound Format files (*.ncsf;*.minincsf)\0";
@@ -37,9 +42,9 @@
 }
 #endif
 
-void XSFPlayer_NCSF::MapNCSFSection(const std::vector<uint8_t> &section)
-{
-	uint32_t size = Get32BitsLE(&section[8]), finalSize = size;
+void XSFPlayer_NCSF::MapNCSFSection(const std::vector<std::uint8_t> &section)
+{
+	std::uint32_t size = Get32BitsLE(&section[8]), finalSize = size;
 	if (this->sdatData.empty())
 		this->sdatData.resize(finalSize, 0);
 	else if (this->sdatData.size() < size)
@@ -183,12 +188,12 @@
 	return XSFPlayer::Load();
 }
 
-static inline int32_t muldiv7(int32_t val, uint8_t mul)
+static inline std::int32_t muldiv7(std::int32_t val, std::uint8_t mul)
 {
 	return mul == 127 ? val : ((val * mul) >> 7);
 }
 
-void XSFPlayer_NCSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples)
+void XSFPlayer_NCSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples)
 {
 	unsigned long mute = this->mutes.to_ulong();
 
@@ -196,22 +201,22 @@
 	{
 		this->secondsIntoPlayback += this->secondsPerSample;
 
-		int32_t leftChannel = 0, rightChannel = 0;
+		std::int32_t leftChannel = 0, rightChannel = 0;
 
 		// I need to advance the sound channels here
 		for (int i = 0; i < 16; ++i)
 		{
 			Channel &chn = this->player.channels[i];
 
-			if (chn.state > CS_NONE)
+			if (chn.state > ChannelState::None)
 			{
-				int32_t sample = chn.GenerateSample();
+				std::int32_t sample = chn.GenerateSample();
 				chn.IncrementSample();
 
 				if (mute & BIT(i))
 					continue;
 
-				uint8_t datashift = chn.reg.volumeDiv;
+				std::uint8_t datashift = chn.reg.volumeDiv;
 				if (datashift == 3)
 					datashift = 4;
 				sample = muldiv7(sample, chn.reg.volumeMul) >> datashift;
@@ -254,7 +259,7 @@
 }
 
 #ifdef _DEBUG
-const Channel &XSFPlayer_NCSF::GetChannel(size_t chanNum) const
+const Channel &XSFPlayer_NCSF::GetChannel(std::size_t chanNum) const
 {
 	return this->player.channels[chanNum];
 }

--- a/src/in_ncsf/XSFPlayer_NCSF.h
+++ b/src/in_ncsf/XSFPlayer_NCSF.h
@@ -10,22 +10,28 @@
 
 #pragma once
 
+#include <bitset>
 #include <memory>
-#include <bitset>
+#include <string>
+#include <vector>
+#ifdef _DEBUG
+# include <cstddef>
+#endif
+#include <cstdint>
 #include "XSFPlayer.h"
 #include "SSEQPlayer/SDAT.h"
 #include "SSEQPlayer/Player.h"
 
 class XSFPlayer_NCSF : public XSFPlayer
 {
-	uint32_t sseq;
-	std::vector<uint8_t> sdatData;
+	std::uint32_t sseq;
+	std::vector<std::uint8_t> sdatData;
 	std::unique_ptr<SDAT> sdat;
 	Player player;
 	double secondsPerSample, secondsIntoPlayback, secondsUntilNextClock;
 	std::bitset<16> mutes;
 
-	void MapNCSFSection(const std::vector<uint8_t> &section);
+	void MapNCSFSection(const std::vector<std::uint8_t> &section);
 	bool MapNCSF(XSFFile *xSFToLoad);
 	bool RecursiveLoadNCSF(XSFFile *xSFToLoad, int level);
 	bool LoadNCSF();
@@ -36,13 +42,13 @@
 #endif
 	~XSFPlayer_NCSF();
 	bool Load();
-	void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples);
+	void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples);
 	void Terminate();
 
 	void SetInterpolation(unsigned interpolation);
 	void SetMutes(const std::bitset<16> &newMutes);
 #ifdef _DEBUG
-	const Channel &GetChannel(size_t chanNum) const;
+	const Channel &GetChannel(std::size_t chanNum) const;
 #endif
 };
 

--- a/src/in_snsf/XSFConfig_SNSF.cpp
+++ b/src/in_snsf/XSFConfig_SNSF.cpp
@@ -9,6 +9,11 @@
  * snes9x.
  */
 
+#include <bitset>
+#include <sstream>
+#include <string>
+#include <cstdint>
+#include "windowsh_wrapper.h"
 #include "XSFConfig_SNSF.h"
 #include "convert.h"
 #include "snes9x/apu/apu.h"
@@ -68,15 +73,15 @@
 
 void XSFConfig_SNSF::GenerateSpecificDialogs()
 {
-	/*this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Sixteen-Bit Sound").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop().
+	/*this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Sixteen-Bit Sound").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop().
 		WithID(idSixteenBitSound));*/
-	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Reverse Stereo").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop().
+	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Reverse Stereo").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop().
 		WithID(idReverseStereo));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Resampler").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10)).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithTabStop().IsDropDownList().
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Resampler").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10)).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithTabStop().IsDropDownList().
 		WithID(idResampler));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder().
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder().
 		WithVerticalScrollbar().WithMultipleSelect().WithTabStop());
 }
 
@@ -140,7 +145,7 @@
 		Settings.ReverseStereo = this->reverseStereo;
 	}
 	else
-		S9xSetSoundControl(static_cast<uint8_t>(this->mutes.to_ulong()) ^ 0xFF);
+		S9xSetSoundControl(static_cast<std::uint8_t>(this->mutes.to_ulong()) ^ 0xFF);
 }
 
 void XSFConfig_SNSF::About(HWND parent)

--- a/src/in_snsf/XSFConfig_SNSF.h
+++ b/src/in_snsf/XSFConfig_SNSF.h
@@ -12,8 +12,11 @@
 #pragma once
 
 #include <bitset>
-#include "XSFPlayer.h"
+#include <string>
+#include "windowsh_wrapper.h"
 #include "XSFConfig.h"
+
+class XSFPlayer;
 
 class XSFConfig_SNSF : public XSFConfig
 {

--- a/src/in_snsf/XSFPlayer_SNSF.cpp
+++ b/src/in_snsf/XSFPlayer_SNSF.cpp
@@ -11,12 +11,17 @@
  * http://www.snes9x.com/
  */
 
+#include <algorithm>
 #include <filesystem>
+#include <memory>
+#include <string>
+#include <vector>
+#include <cstddef>
+#include <cstdint>
 #include <zlib.h>
-#include "convert.h"
+#include "XSFCommon.h"
+#include "XSFConfig_SNSF.h"
 #include "XSFPlayer.h"
-#include "XSFConfig_SNSF.h"
-#include "XSFCommon.h"
 
 #undef min
 #undef max
@@ -38,7 +43,7 @@
 #endif
 	~XSFPlayer_SNSF() { this->Terminate(); }
 	bool Load();
-	void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples);
+	void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples);
 	void Terminate();
 };
 
@@ -61,15 +66,15 @@
 
 static struct
 {
-	std::vector<uint8_t> rom, sram;
+	std::vector<std::uint8_t> rom, sram;
 	bool first;
 	unsigned base;
-} loaderwork = { std::vector<uint8_t>(), std::vector<uint8_t>(), false, 0 };
+} loaderwork = { std::vector<std::uint8_t>(), std::vector<std::uint8_t>(), false, 0 };
 
 class BUFFER
 {
 public:
-	std::vector<uint8_t> buf;
+	std::vector<std::uint8_t> buf;
 	unsigned fil, cur, len;
 	BUFFER() : buf(), fil(0), cur(0), len(0) { }
 	bool Init()
@@ -107,11 +112,11 @@
 	return true;
 }
 
-static void MapSNSFSection(const std::vector<uint8_t> &section)
+static void MapSNSFSection(const std::vector<std::uint8_t> &section)
 {
 	auto &data = loaderwork.rom;
 
-	uint32_t offset = Get32BitsLE(&section[0]), size = Get32BitsLE(&section[4]), finalSize = size + offset;
+	std::uint32_t offset = Get32BitsLE(&section[0]), size = Get32BitsLE(&section[4]), finalSize = size + offset;
 	if (!loaderwork.first)
 	{
 		loaderwork.first = true;
@@ -136,17 +141,17 @@
 
 	if (!reservedSection.empty())
 	{
-		size_t reservedPosition = 0, reservedSize = reservedSection.size();
+		std::size_t reservedPosition = 0, reservedSize = reservedSection.size();
 		while (reservedPosition + 8 < reservedSize)
 		{
-			uint32_t type = Get32BitsLE(&reservedSection[reservedPosition]), size = Get32BitsLE(&reservedSection[reservedPosition + 4]);
+			std::uint32_t type = Get32BitsLE(&reservedSection[reservedPosition]), size = Get32BitsLE(&reservedSection[reservedPosition + 4]);
 			if (!type)
 			{
 				if (loaderwork.sram.empty())
 					loaderwork.sram.resize(0x20000, 0xFF);
 				if (reservedPosition + 8 + size > reservedSize)
 					return false;
-				uint32_t offset = Get32BitsLE(&reservedSection[reservedPosition + 8]);
+				std::uint32_t offset = Get32BitsLE(&reservedSection[reservedPosition + 8]);
 				if (size > 4 && loaderwork.sram.size() > offset)
 				{
 					auto len = std::min(size - 4, loaderwork.sram.size() - offset);
@@ -264,7 +269,7 @@
 	return XSFPlayer::Load();
 }
 
-void XSFPlayer_SNSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples)
+void XSFPlayer_SNSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples)
 {
 	unsigned bytes = samples << 2;
 	while (bytes)

--- a/src/in_xsf_framework/DialogBuilder.cpp
+++ b/src/in_xsf_framework/DialogBuilder.cpp
@@ -3,13 +3,20 @@
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
  */
 
+#include <algorithm>
+#include <memory>
+#include <utility>
+#include <vector>
+#include <cstdint>
+#include "windowsh_wrapper.h"
 #include "DialogBuilder.h"
+#include "XSFCommon.h"
 
 // Code modified from the following answer on Stack Overflow:
 // http://stackoverflow.com/a/3407254
-static inline uint32_t getNextMultipleOf4(uint32_t origNum)
-{
-	uint32_t remainder = origNum % 4;
+static inline std::uint32_t getNextMultipleOf4(std::uint32_t origNum)
+{
+	std::uint32_t remainder = origNum % 4;
 	if (!remainder)
 		return origNum;
 	return origNum + 4 - remainder;
@@ -20,16 +27,16 @@
 	Point<short> newPosition = child.position;
 	if (this->relativePosition.y != -1)
 	{
-		if (this->positionType == FROM_TOP || this->positionType == FROM_TOPLEFT || this->positionType == FROM_TOPRIGHT)
+		if (this->positionType == PositionType::FromTop || this->positionType == PositionType::FromTopLeft || this->positionType == PositionType::FromTopRight)
 			newPosition.y = other.position.y + this->relativePosition.y;
-		if (this->positionType == FROM_BOTTOM || this->positionType == FROM_BOTTOMLEFT || this->positionType == FROM_BOTTOMRIGHT)
+		if (this->positionType == PositionType::FromBottom || this->positionType == PositionType::FromBottomLeft || this->positionType == PositionType::FromBottomRight)
 			newPosition.y = other.position.y + other.size.height + this->relativePosition.y;
 	}
 	if (this->relativePosition.x != -1)
 	{
-		if (this->positionType == FROM_LEFT || this->positionType == FROM_TOPLEFT || this->positionType == FROM_BOTTOMLEFT)
+		if (this->positionType == PositionType::FromLeft || this->positionType == PositionType::FromTopLeft || this->positionType == PositionType::FromBottomLeft)
 			newPosition.x = other.position.x + this->relativePosition.x;
-		if (this->positionType == FROM_RIGHT || this->positionType == FROM_TOPRIGHT || this->positionType == FROM_BOTTOMRIGHT)
+		if (this->positionType == PositionType::FromRight || this->positionType == PositionType::FromTopRight || this->positionType == PositionType::FromBottomRight)
 			newPosition.x = other.position.x + other.size.width + this->relativePosition.x;
 	}
 	return newPosition;
@@ -44,15 +51,15 @@
 		if (control->relativePosition)
 		{
 			bool valid = true;
-			if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT)
+			if (!doRightAndBottom && control->relativePosition->type == RelativePosition::BaseType::ToParent)
 			{
 				switch (control->relativePosition->positionType)
 				{
-					case RelativePosition::FROM_BOTTOM:
-					case RelativePosition::FROM_BOTTOMLEFT:
-					case RelativePosition::FROM_BOTTOMRIGHT:
-					case RelativePosition::FROM_RIGHT:
-					case RelativePosition::FROM_TOPRIGHT:
+					case RelativePosition::PositionType::FromBottom:
+					case RelativePosition::PositionType::FromBottomLeft:
+					case RelativePosition::PositionType::FromBottomRight:
+					case RelativePosition::PositionType::FromRight:
+					case RelativePosition::PositionType::FromTopRight:
 						valid = false;
 						break;
 					default:
@@ -62,7 +69,7 @@
 			if (valid)
 			{
 				Rect<short> other = this->rect;
-				if (control->relativePosition->type == RelativePosition::TO_SIBLING)
+				if (control->relativePosition->type == RelativePosition::BaseType::ToSibling)
 				{
 					short siblingsBack = dynamic_cast<const RelativePositionToSibling *>(control->relativePosition.get())->siblingsBack;
 					if (x - siblingsBack >= 0)
@@ -82,15 +89,15 @@
 		bool usePosition = true;
 		if (control->relativePosition)
 		{
-			if (control->relativePosition->type == RelativePosition::TO_PARENT)
+			if (control->relativePosition->type == RelativePosition::BaseType::ToParent)
 			{
 				switch (control->relativePosition->positionType)
 				{
-					case RelativePosition::FROM_BOTTOM:
-					case RelativePosition::FROM_BOTTOMLEFT:
-					case RelativePosition::FROM_BOTTOMRIGHT:
-					case RelativePosition::FROM_RIGHT:
-					case RelativePosition::FROM_TOPRIGHT:
+					case RelativePosition::PositionType::FromBottom:
+					case RelativePosition::PositionType::FromBottomLeft:
+					case RelativePosition::PositionType::FromBottomRight:
+					case RelativePosition::PositionType::FromRight:
+					case RelativePosition::PositionType::FromTopRight:
 						usePosition = false;
 						/*if (control->relativePosition->relativePosition.x != -1 && control->rect.size.width + control->relativePosition->relativePosition.x > maxOtherWidth)
 							maxOtherWidth = control->rect.size.width + control->relativePosition->relativePosition.x;
@@ -114,27 +121,27 @@
 	this->rect.size.height = (maxY - this->rect.position.y) + maxOtherHeight + 7;
 }
 
-uint16_t DialogTemplate::DialogGroup::GetControlCount() const
-{
-	uint16_t count = 1;
+std::uint16_t DialogTemplate::DialogGroup::GetControlCount() const
+{
+	std::uint16_t count = 1;
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) { count += control->GetControlCount(); });
 	return count;
 }
 
-std::vector<uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() const
-{
-	auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->groupName.length() + 1)), 0);
-
-	*reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | BS_GROUPBOX | this->style;
-	*reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle;
-	*reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x;
-	*reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y;
-	*reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width;
-	*reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height;
-	*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
-	*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF;
-	*reinterpret_cast<uint16_t *>(&data[20]) = 0x0080;
-	std::copy_n(this->groupName.c_str(), this->groupName.length(), reinterpret_cast<wchar_t *>(&data[22]));
+std::vector<std::uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() const
+{
+	auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->groupName.length() + 1)), 0);
+
+	*reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | BS_GROUPBOX | this->style;
+	*reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle;
+	*reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x;
+	*reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y;
+	*reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width;
+	*reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height;
+	*reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<std::uint16_t>(this->id);
+	*reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF;
+	*reinterpret_cast<std::uint16_t *>(&data[20]) = 0x0080;
+	CopyToString(this->groupName, reinterpret_cast<wchar_t *>(&data[22]));
 
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control)
 	{
@@ -145,44 +152,44 @@
 	return data;
 }
 
-std::vector<uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlTemplate() const
-{
-	auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t)), 0);
-
-	*reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style;
-	*reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle;
-	*reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x;
-	*reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y;
-	*reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width;
-	*reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height;
-	*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
-	*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF;
-	*reinterpret_cast<uint16_t *>(&data[20]) = this->type;
+std::vector<std::uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlTemplate() const
+{
+	auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t)), 0);
+
+	*reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style;
+	*reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle;
+	*reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x;
+	*reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y;
+	*reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width;
+	*reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height;
+	*reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
+	*reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF;
+	*reinterpret_cast<std::uint16_t *>(&data[20]) = this->type;
 
 	return data;
 }
 
-std::vector<uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemplate() const
-{
-	auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->label.length() + 1)), 0);
-
-	*reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style;
-	*reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle;
-	*reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x;
-	*reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y;
-	*reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width;
-	*reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height;
-	*reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id);
-	*reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF;
-	*reinterpret_cast<uint16_t *>(&data[20]) = this->type;
-	std::copy_n(this->label.c_str(), this->label.length(), reinterpret_cast<wchar_t *>(&data[22]));
+std::vector<std::uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemplate() const
+{
+	auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->label.length() + 1)), 0);
+
+	*reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style;
+	*reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle;
+	*reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x;
+	*reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y;
+	*reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width;
+	*reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height;
+	*reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<std::uint16_t>(this->id);
+	*reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF;
+	*reinterpret_cast<std::uint16_t *>(&data[20]) = this->type;
+	CopyToString(this->label, reinterpret_cast<wchar_t *>(&data[22]));
 
 	return data;
 }
 
-uint16_t DialogTemplate::GetTotalControlCount() const
-{
-	uint16_t count = 0;
+std::uint16_t DialogTemplate::GetTotalControlCount() const
+{
+	std::uint16_t count = 0;
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) { count += control->GetControlCount(); });
 	return count;
 }
@@ -198,32 +205,32 @@
 
 void DialogTemplate::AddEditBoxControl(const DialogControlBuilder<DialogEditBoxBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogEditBox::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogEditBox::CreateControl(builder), builder);
 }
 
 void DialogTemplate::AddLabelControl(const DialogControlBuilder<DialogLabelBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogLabel::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogLabel::CreateControl(builder), builder);
 }
 
 void DialogTemplate::AddCheckBoxControl(const DialogControlBuilder<DialogCheckBoxBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogButton::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogButton::CreateControl(builder), builder);
 }
 
 void DialogTemplate::AddButtonControl(const DialogControlBuilder<DialogButtonBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogButton::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogButton::CreateControl(builder), builder);
 }
 
 void DialogTemplate::AddListBoxControl(const DialogControlBuilder<DialogListBoxBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogListBox::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogListBox::CreateControl(builder), builder);
 }
 
 void DialogTemplate::AddComboBoxControl(const DialogControlBuilder<DialogComboBoxBuilder> &builder)
 {
-	this->AddControlToGroup(std::move(DialogComboBox::CreateControl(builder)), builder);
+	this->AddControlToGroup(DialogComboBox::CreateControl(builder), builder);
 }
 
 bool DialogTemplate::CalculateControlPosition(short index, bool doRightAndBottom)
@@ -232,15 +239,15 @@
 	bool valid = true;
 	if (control->relativePosition)
 	{
-		if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT)
+		if (!doRightAndBottom && control->relativePosition->type == RelativePosition::BaseType::ToParent)
 		{
 			switch (control->relativePosition->positionType)
 			{
-				case RelativePosition::FROM_BOTTOM:
-				case RelativePosition::FROM_BOTTOMLEFT:
-				case RelativePosition::FROM_BOTTOMRIGHT:
-				case RelativePosition::FROM_RIGHT:
-				case RelativePosition::FROM_TOPRIGHT:
+				case RelativePosition::PositionType::FromBottom:
+				case RelativePosition::PositionType::FromBottomLeft:
+				case RelativePosition::PositionType::FromBottomRight:
+				case RelativePosition::PositionType::FromRight:
+				case RelativePosition::PositionType::FromTopRight:
 					valid = false;
 					break;
 				default:
@@ -250,7 +257,7 @@
 		if (valid)
 		{
 			Rect<short> other = Rect<short>(Point<short>(), this->size);
-			if (control->relativePosition->type == RelativePosition::TO_SIBLING)
+			if (control->relativePosition->type == RelativePosition::BaseType::ToSibling)
 			{
 				short siblingsBack = dynamic_cast<const RelativePositionToSibling *>(control->relativePosition.get())->siblingsBack;
 				if (index - siblingsBack >= 0)
@@ -270,15 +277,15 @@
 		bool usePosition = true;
 		if (control->relativePosition)
 		{
-			if (control->relativePosition->type == RelativePosition::TO_PARENT)
+			if (control->relativePosition->type == RelativePosition::BaseType::ToParent)
 			{
 				switch (control->relativePosition->positionType)
 				{
-					case RelativePosition::FROM_BOTTOM:
-					case RelativePosition::FROM_BOTTOMLEFT:
-					case RelativePosition::FROM_BOTTOMRIGHT:
-					case RelativePosition::FROM_RIGHT:
-					case RelativePosition::FROM_TOPRIGHT:
+					case RelativePosition::PositionType::FromBottom:
+					case RelativePosition::PositionType::FromBottomLeft:
+					case RelativePosition::PositionType::FromBottomRight:
+					case RelativePosition::PositionType::FromRight:
+					case RelativePosition::PositionType::FromTopRight:
 						usePosition = false;
 						/*if (control->relativePosition->relativePosition.x != -1 && control->rect.size.width + control->relativePosition->relativePosition.x > maxOtherWidth)
 							maxOtherWidth = control->rect.size.width + control->relativePosition->relativePosition.x;
@@ -310,7 +317,7 @@
 	{
 		auto &control = this->controls[x];
 		bool valid = this->CalculateControlPosition(x, false);
-		if (valid && control->controlType == GROUP_CONTROL)
+		if (valid && control->controlType == DialogControlType::Group)
 		{
 			dynamic_cast<DialogGroup *>(control.get())->CalculatePositions(false);
 			// Technically step 2, but calculate the size of the group
@@ -323,7 +330,7 @@
 	for (x = 0; x < num; ++x)
 	{
 		auto &control = this->controls[x];
-		if (control->controlType != GROUP_CONTROL)
+		if (control->controlType != DialogControlType::Group)
 			continue;
 		control->rect.size.width = maxGroupWidth;
 		dynamic_cast<DialogGroup *>(control.get())->CalculatePositions(true);
@@ -338,19 +345,19 @@
 const DLGTEMPLATE *DialogTemplate::GenerateTemplate()
 {
 	this->templateData.clear();
-	uint16_t controlCount = this->GetTotalControlCount();
+	std::uint16_t controlCount = this->GetTotalControlCount();
 	this->templateData.resize(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->title.length() + 1 + (this->fontName.empty() ? 0 : this->fontName.length() + 1))), 0);
 
-	*reinterpret_cast<uint32_t *>(&this->templateData[0]) = this->style | (this->fontName.empty() ? 0 : DS_SETFONT);
-	*reinterpret_cast<uint32_t *>(&this->templateData[4]) = this->exstyle;
-	*reinterpret_cast<uint16_t *>(&this->templateData[8]) = controlCount;
-	*reinterpret_cast<uint16_t *>(&this->templateData[14]) = this->size.width;
-	*reinterpret_cast<uint16_t *>(&this->templateData[16]) = this->size.height;
-	std::copy_n(this->title.c_str(), this->title.length(), reinterpret_cast<wchar_t *>(&this->templateData[22]));
+	*reinterpret_cast<std::uint32_t *>(&this->templateData[0]) = this->style | (this->fontName.empty() ? 0 : DS_SETFONT);
+	*reinterpret_cast<std::uint32_t *>(&this->templateData[4]) = this->exstyle;
+	*reinterpret_cast<std::uint16_t *>(&this->templateData[8]) = controlCount;
+	*reinterpret_cast<std::uint16_t *>(&this->templateData[14]) = this->size.width;
+	*reinterpret_cast<std::uint16_t *>(&this->templateData[16]) = this->size.height;
+	CopyToString(this->title, reinterpret_cast<wchar_t *>(&this->templateData[22]));
 	if (!this->fontName.empty())
 	{
-		*reinterpret_cast<uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts;
-		std::copy_n(this->fontName.c_str(), this->fontName.length(), reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)]));
+		*reinterpret_cast<std::uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts;
+		CopyToString(this->fontName, reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)]));
 	}
 
 	std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control)

--- a/src/in_xsf_framework/DialogBuilder.h
+++ b/src/in_xsf_framework/DialogBuilder.h
@@ -5,14 +5,15 @@
 
 #pragma once
 
+#include <algorithm>
+#include <memory>
+#include <stdexcept>
 #include <string>
-#include <memory>
+#include <utility>
 #include <vector>
-#include <algorithm>
-#include <stdexcept>
 #include <cstdint>
-#include "XSFCommon.h"
 #include "windowsh_wrapper.h"
+#include "convert.h"
 
 template<typename T> struct Point
 {
@@ -44,21 +45,21 @@
 {
 public:
 	Point<short> relativePosition;
-	enum BaseType
-	{
-		TO_PARENT,
-		TO_SIBLING
+	enum class BaseType
+	{
+		ToParent,
+		ToSibling
 	} type;
-	enum PositionType
-	{
-		FROM_TOP,
-		FROM_BOTTOM,
-		FROM_LEFT,
-		FROM_RIGHT,
-		FROM_TOPLEFT,
-		FROM_BOTTOMLEFT,
-		FROM_TOPRIGHT,
-		FROM_BOTTOMRIGHT
+	enum class PositionType
+	{
+		FromTop,
+		FromBottom,
+		FromLeft,
+		FromRight,
+		FromTopLeft,
+		FromBottomLeft,
+		FromTopRight,
+		FromBottomRight
 	} positionType;
 
 	RelativePosition(const Point<short> &RelPosition, BaseType Type, PositionType PosType) : relativePosition(RelPosition), type(Type), positionType(PosType) { }
@@ -70,7 +71,7 @@
 class RelativePositionToParent : public RelativePosition
 {
 public:
-	RelativePositionToParent(const Point<short> &RelPosition, PositionType PosType) : RelativePosition(RelPosition, TO_PARENT, PosType) { }
+	RelativePositionToParent(const Point<short> &RelPosition, PositionType PosType) : RelativePosition(RelPosition, BaseType::ToParent, PosType) { }
 	RelativePositionToParent *Clone() const { return new RelativePositionToParent(this->relativePosition, this->positionType); }
 };
 
@@ -79,20 +80,20 @@
 public:
 	short siblingsBack;
 
-	RelativePositionToSibling(const Point<short> &RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, TO_SIBLING, PosType), siblingsBack(SiblingsBack) { }
+	RelativePositionToSibling(const Point<short> &RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, BaseType::ToSibling, PosType), siblingsBack(SiblingsBack) { }
 	RelativePositionToSibling *Clone() const { return new RelativePositionToSibling(this->relativePosition, this->positionType, this->siblingsBack); }
 };
 
-enum DialogControlType
-{
-	NO_CONTROL,
-	GROUP_CONTROL,
-	EDITBOX_CONTROL,
-	LABEL_CONTROL,
-	CHECKBOX_CONTROL,
-	BUTTON_CONTROL,
-	LISTBOX_CONTROL,
-	COMBOBOX_CONTROL
+enum class DialogControlType
+{
+	None,
+	Group,
+	EditBox,
+	Label,
+	CheckBox,
+	Button,
+	ListBox,
+	ComboBox
 };
 
 class DialogTemplate;
@@ -102,14 +103,14 @@
 protected:
 	friend class DialogTemplate;
 	std::wstring title, fontName;
-	uint32_t style, exstyle;
-	uint16_t fontSizeInPts;
+	std::uint32_t style, exstyle;
+	std::uint16_t fontSizeInPts;
 	Size<short> size;
 	bool resetControls;
 public:
 	DialogBuilder() : title(L""), fontName(L""), style(0), exstyle(0), fontSizeInPts(0), size(), resetControls(false) { }
 	DialogBuilder &WithTitle(const std::wstring &Title) { this->title = Title; return *this; }
-	DialogBuilder &WithFont(const std::wstring &FontName, uint16_t FontSizeInPts) { this->fontName = FontName; this->fontSizeInPts = FontSizeInPts; return *this; }
+	DialogBuilder &WithFont(const std::wstring &FontName, std::uint16_t FontSizeInPts) { this->fontName = FontName; this->fontSizeInPts = FontSizeInPts; return *this; }
 	DialogBuilder &WithSize(short Width, short Height) { this->size.width = Width; this->size.height = Height; return *this; }
 	DialogBuilder &WithSize(const Size<short> &Sz) { this->size = Sz; return *this; }
 	DialogBuilder &ResetControls(bool Reset = true) { this->resetControls = Reset; return *this; }
@@ -139,7 +140,7 @@
 protected:
 	friend class DialogTemplate;
 	DialogControlType controlType;
-	uint32_t style, exstyle;
+	std::uint32_t style, exstyle;
 	Rect<short> rect;
 	short id;
 	int index;
@@ -147,7 +148,7 @@
 
 	T &me() { return dynamic_cast<T &>(*this); }
 public:
-	DialogControlBuilder(DialogControlType Type = NO_CONTROL) : controlType(Type), style(0), exstyle(0), rect(), id(-1), index(-1), relativePosition() { }
+	DialogControlBuilder(DialogControlType Type = DialogControlType::None) : controlType(Type), style(0), exstyle(0), rect(), id(-1), index(-1), relativePosition() { }
 	virtual ~DialogControlBuilder() { }
 	T &WithPosition(short X, short Y) { this->rect.position.x = X; this->rect.position.y = Y; return this->me(); }
 	T &WithPosition(const Point<short> &Position) { this->rect.position = Position; return this->me(); }
@@ -182,7 +183,7 @@
 	friend class DialogTemplate;
 	std::wstring groupName;
 public:
-	DialogGroupBuilder(const std::wstring &newGroupName) : DialogControlBuilder(GROUP_CONTROL), groupName(newGroupName) { }
+	DialogGroupBuilder(const std::wstring &newGroupName) : DialogControlBuilder(DialogControlType::Group), groupName(newGroupName) { }
 };
 
 template<class T> class DialogInGroupBuilder : public DialogControlBuilder<T>
@@ -200,7 +201,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogEditBoxBuilder() : DialogInGroupBuilder(EDITBOX_CONTROL) { }
+	DialogEditBoxBuilder() : DialogInGroupBuilder(DialogControlType::EditBox) { }
 	DialogEditBoxBuilder &IsLeftJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_LEFT; return this->me(); }
 	DialogEditBoxBuilder &IsCenterJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_CENTER; return this->me(); }
 	DialogEditBoxBuilder &IsRightJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_RIGHT; return this->me(); }
@@ -229,7 +230,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogLabelBuilder(const std::wstring &Label) : DialogControlWithLabelBuilder(LABEL_CONTROL, Label) { }
+	DialogLabelBuilder(const std::wstring &Label) : DialogControlWithLabelBuilder(DialogControlType::Label, Label) { }
 	DialogLabelBuilder &IsLeftJustified(bool WithWordWrap = false)
 	{
 		this->style &= ~(SS_LEFT | SS_CENTER | SS_RIGHT | SS_LEFTNOWORDWRAP);
@@ -311,7 +312,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogButtonBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(BUTTON_CONTROL, Label) { }
+	DialogButtonBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(DialogControlType::Button, Label) { }
 	DialogButtonBuilder &IsDefault(bool Default = true) { if (Default) this->style |= BS_DEFPUSHBUTTON; else this->style &= ~BS_DEFPUSHBUTTON; return this->me(); }
 };
 
@@ -320,7 +321,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogCheckBoxBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(CHECKBOX_CONTROL, Label) { this->style |= BS_AUTOCHECKBOX; }
+	DialogCheckBoxBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(DialogControlType::CheckBox, Label) { this->style |= BS_AUTOCHECKBOX; }
 	DialogCheckBoxBuilder &WithTextOnLeft(bool TextOnLeft = true) { if (TextOnLeft) this->style |= BS_LEFTTEXT; else this->style &= ~BS_LEFTTEXT; return this->me(); }
 	DialogCheckBoxBuilder &LikePushButton(bool PushButton = true) { if (PushButton) this->style |= BS_PUSHLIKE; else this->style &= ~BS_PUSHLIKE; return this->me(); }
 };
@@ -330,7 +331,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogListBoxBuilder() : DialogInGroupBuilder(LISTBOX_CONTROL) { }
+	DialogListBoxBuilder() : DialogInGroupBuilder(DialogControlType::ListBox) { }
 	DialogListBoxBuilder &WithNotify(bool Notify = true) { if (Notify) this->style |= LBS_NOTIFY; else this->style &= ~LBS_NOTIFY; return this->me(); }
 	DialogListBoxBuilder &WithSort(bool Sort = true) { if (Sort) this->style |= LBS_SORT; else this->style &= ~LBS_SORT; return this->me(); }
 	DialogListBoxBuilder &WithMultipleSelect(bool MultipleSelect = true) { if (MultipleSelect) this->style |= LBS_MULTIPLESEL; else this->style &= ~LBS_MULTIPLESEL; return this->me(); }
@@ -348,7 +349,7 @@
 protected:
 	friend class DialogTemplate;
 public:
-	DialogComboBoxBuilder() : DialogInGroupBuilder(COMBOBOX_CONTROL) { }
+	DialogComboBoxBuilder() : DialogInGroupBuilder(DialogControlType::ComboBox) { }
 	DialogComboBoxBuilder &IsSimple() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_SIMPLE; return this->me(); }
 	DialogComboBoxBuilder &IsDropDown() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_DROPDOWN; return this->me(); }
 	DialogComboBoxBuilder &IsDropDownList() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_DROPDOWNLIST; return this->me(); }
@@ -372,13 +373,13 @@
 	{
 	protected:
 		DialogControlType controlType;
-		uint32_t style, exstyle;
+		std::uint32_t style, exstyle;
 		Rect<short> rect;
 		short id;
 		std::unique_ptr<RelativePosition> relativePosition;
 
 		friend class DialogTemplate;
-		DialogControl() : controlType(NO_CONTROL), style(0), exstyle(0), rect(), id(-1), relativePosition() { }
+		DialogControl() : controlType(DialogControlType::None), style(0), exstyle(0), rect(), id(-1), relativePosition() { }
 		DialogControl(const DialogControl &control) : controlType(control.controlType), style(control.style), exstyle(control.exstyle), rect(control.rect), id(control.id),
 			relativePosition(control.relativePosition ? control.relativePosition->Clone() : nullptr) { }
 		DialogControl &operator=(const DialogControl &control)
@@ -411,9 +412,9 @@
 
 			return control;
 		}
-		virtual uint16_t GetControlCount() const { return 1; }
+		virtual std::uint16_t GetControlCount() const { return 1; }
 		virtual short GetControlHeight() const { return this->rect.size.height; }
-		virtual std::vector<uint8_t> GenerateControlTemplate() const = 0;
+		virtual std::vector<std::uint8_t> GenerateControlTemplate() const = 0;
 		virtual DialogControl *Clone() const = 0;
 	};
 
@@ -452,15 +453,15 @@
 		}
 		void CalculatePositions(bool doRightAndBottom = false);
 		void CalculateSize();
-		uint16_t GetControlCount() const;
-		std::vector<uint8_t> GenerateControlTemplate() const;
+		std::uint16_t GetControlCount() const;
+		std::vector<std::uint8_t> GenerateControlTemplate() const;
 		DialogGroup *Clone() const { return new DialogGroup(*this); }
 	};
 
 	class DialogControlWithoutLabel : public DialogControl
 	{
 	protected:
-		uint16_t type;
+		std::uint16_t type;
 
 		friend class DialogTemplate;
 		friend class DialogControl;
@@ -475,7 +476,7 @@
 			return *this;
 		}
 	public:
-		template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, uint16_t Type)
+		template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, std::uint16_t Type)
 		{
 			auto control = DialogControl::CreateControl<Control>(builder);
 
@@ -483,14 +484,14 @@
 
 			return control;
 		}
-		virtual std::vector<uint8_t> GenerateControlTemplate() const;
+		virtual std::vector<std::uint8_t> GenerateControlTemplate() const;
 		virtual DialogControlWithoutLabel *Clone() const { return new DialogControlWithoutLabel(*this); }
 	};
 
 	class DialogControlWithLabel : public DialogControl
 	{
 	protected:
-		uint16_t type;
+		std::uint16_t type;
 		std::wstring label;
 
 		friend class DialogTemplate;
@@ -507,7 +508,7 @@
 			return *this;
 		}
 	public:
-		template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, uint16_t Type)
+		template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, std::uint16_t Type)
 		{
 			auto control = DialogControl::CreateControl<Control>(builder);
 
@@ -516,7 +517,7 @@
 
 			return control;
 		}
-		virtual std::vector<uint8_t> GenerateControlTemplate() const;
+		virtual std::vector<std::uint8_t> GenerateControlTemplate() const;
 		virtual DialogControlWithLabel *Clone() const { return new DialogControlWithLabel(*this); }
 	};
 
@@ -587,12 +588,12 @@
 	};
 
 	std::wstring title;
-	uint32_t style, exstyle;
+	std::uint32_t style, exstyle;
 	std::wstring fontName;
-	uint16_t fontSizeInPts;
+	std::uint16_t fontSizeInPts;
 	Size<short> size;
 	DialogTemplate::Controls controls;
-	std::vector<uint8_t> templateData;
+	std::vector<std::uint8_t> templateData;
 
 	template<typename Builder> void AddControlToGroup(std::unique_ptr<DialogControl> &&control, const DialogControlBuilder<Builder> &builder)
 	{
@@ -608,7 +609,7 @@
 		{
 			for (auto curr = this->controls.begin(), end = this->controls.end(); curr != end; ++curr)
 			{
-				if ((*curr)->controlType != GROUP_CONTROL)
+				if ((*curr)->controlType != DialogControlType::Group)
 					continue;
 				DialogGroup *group = dynamic_cast<DialogGroup *>(curr->get());
 				if (group->groupName == groupBuilder.groupName)
@@ -623,7 +624,7 @@
 			throw std::runtime_error("Group " + ConvertFuncs::WStringToString(groupBuilder.groupName) + " was not found.");
 		}
 	}
-	uint16_t GetTotalControlCount() const;
+	std::uint16_t GetTotalControlCount() const;
 	bool CalculateControlPosition(short index, bool doRightAndBottom = false);
 	void CalculateSize();
 public:

--- a/src/in_xsf_framework/TagList.cpp
+++ b/src/in_xsf_framework/TagList.cpp
@@ -7,7 +7,9 @@
  */
 
 #include <algorithm>
+#include <string>
 #include "TagList.h"
+#include "eqstr.h"
 
 eq_str TagList::eqstr;
 

--- a/src/in_xsf_framework/TagList.h
+++ b/src/in_xsf_framework/TagList.h
@@ -9,6 +9,7 @@
 #pragma once
 
 #include <map>
+#include <string>
 #include <vector>
 #include "eqstr.h"
 #include "ltstr.h"

--- a/src/in_xsf_framework/XSFCommon.h
+++ b/src/in_xsf_framework/XSFCommon.h
@@ -12,6 +12,7 @@
 #include <string>
 #define _USE_MATH_DEFINES
 #include <cmath>
+#include <cstddef>
 #include <cstdint>
 #include <cwchar>
 #include <cstring>
@@ -25,14 +26,14 @@
 	return diff <= tolerance * std::abs(x) && diff <= tolerance * std::abs(y);
 }
 
-inline uint32_t Get32BitsLE(const uint8_t *input)
+inline std::uint32_t Get32BitsLE(const std::uint8_t *input)
 {
 	return input[0] | (input[1] << 8) | (input[2] << 16) | (input[3] << 24);
 }
 
-inline uint32_t Get32BitsLE(std::ifstream &input)
+inline std::uint32_t Get32BitsLE(std::ifstream &input)
 {
-	uint8_t bytes[4];
+	std::uint8_t bytes[4];
 	input.read(reinterpret_cast<char *>(bytes), 4);
 	return Get32BitsLE(bytes);
 }
@@ -44,7 +45,7 @@
 	if (value < 1)
 		return 1;
 	--value;
-	for (size_t i = 1; i < sizeof(T) * std::numeric_limits<unsigned char>::digits; i <<= 1)
+	for (std::size_t i = 1; i < sizeof(T) * std::numeric_limits<unsigned char>::digits; i <<= 1)
 		value |= value >> i;
 	return value + 1;
 }
@@ -60,21 +61,21 @@
 
 inline void CopyToString(const std::wstring &src, wchar_t *dst)
 {
-	wcscpy(dst, src.c_str());
+	std::wcscpy(dst, src.c_str());
 }
 
 inline void CopyToString(const std::string &src, wchar_t *dst)
 {
-	wcscpy(dst, ConvertFuncs::StringToWString(src).c_str());
+	std::wcscpy(dst, ConvertFuncs::StringToWString(src).c_str());
 }
 
 inline void CopyToString(const std::string &src, char *dst)
 {
-	strcpy(dst, src.c_str());
+	std::strcpy(dst, src.c_str());
 }
 
 inline void CopyToString(const std::wstring &src, char *dst)
 {
-	strcpy(dst, ConvertFuncs::WStringToString(src).c_str());
+	std::strcpy(dst, ConvertFuncs::WStringToString(src).c_str());
 }
 

--- a/src/in_xsf_framework/XSFConfig.cpp
+++ b/src/in_xsf_framework/XSFConfig.cpp
@@ -5,7 +5,13 @@
  * Partially based on the vio*sf framework
  */
 
+#include <algorithm>
+#include <string>
+#include <vector>
+#include "windowsh_wrapper.h"
+#include <windowsx.h>
 #include "XSFConfig.h"
+#include "XSFFile.h"
 #include "XSFPlayer.h"
 #include "convert.h"
 
@@ -38,10 +44,10 @@
 std::string XSFConfig::initDefaultFade = "5";
 std::string XSFConfig::initTitleFormat = "%game%[ - [%disc%.]%track%] - %title%";
 double XSFConfig::initVolume = 1.0;
-VolumeType XSFConfig::initVolumeType = VOLUMETYPE_REPLAYGAIN_ALBUM;
-PeakType XSFConfig::initPeakType = PEAKTYPE_REPLAYGAIN_TRACK;
-
-XSFConfig::XSFConfig() : playInfinitely(false), skipSilenceOnStartSec(0), detectSilenceSec(0), defaultLength(0), defaultFade(0), volume(0.0), volumeType(VOLUMETYPE_NONE), peakType(PEAKTYPE_NONE),
+VolumeType XSFConfig::initVolumeType = VolumeType::ReplayGainAlbum;
+PeakType XSFConfig::initPeakType = PeakType::ReplayGainTrack;
+
+XSFConfig::XSFConfig() : playInfinitely(false), skipSilenceOnStartSec(0), detectSilenceSec(0), defaultLength(0), defaultFade(0), volume(0.0), volumeType(VolumeType::None), peakType(PeakType::None),
 	sampleRate(0), titleFormat(""), configDialog(), configDialogProperty(), infoDialog(), supportedSampleRates(), configIO(XSFConfigIO::Create())
 {
 }
@@ -95,84 +101,84 @@
 void XSFConfig::GenerateDialogs()
 {
 	this->infoDialog = DialogBuilder().IsPopup().WithBorder().WithDialogFrame().WithDialogModalFrame().WithSystemMenu().WithFont(L"MS Shell Dlg", 8);
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Title:").WithSize(50, 8).WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(7, 10)).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Title:").WithSize(50, 8).WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(7, 10)).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoTitle));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Artist:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Artist:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoArtist));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Game:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Game:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoGame));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Year:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Year:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoYear));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Genre:").WithSize(25, 8).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, 3)).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(140, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Genre:").WithSize(25, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, 3)).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(140, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoGenre));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Copyright:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 4).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Copyright:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 4).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder().
 		WithTabStop().WithID(idInfoCopyright));
-	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Comment:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified());
-	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 54).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoVScroll().WithBorder().
+	this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Comment:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified());
+	this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 54).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoVScroll().WithBorder().
 		WithTabStop().WithID(idInfoComment).WithVerticalScrollbar().WithWantReturn().IsMultiline());
 
 	this->configDialog = DialogBuilder().WithTitle(ConvertFuncs::StringToWString(XSFConfig::commonName + " v" + XSFConfig::versionNumber)).IsPopup().WithBorder().WithDialogFrame().WithDialogModalFrame().WithSystemMenu().WithFont(L"MS Shell Dlg", 8);
-	this->configDialog.AddGroupControl(DialogGroupBuilder(L"General").WithRelativePositionToParent(RelativePositionToParent::FROM_TOPLEFT, Point<short>(7, 7)));
-	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Play infinitely").WithSize(60, 10).InGroup(L"General").WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 11)).WithTabStop().
+	this->configDialog.AddGroupControl(DialogGroupBuilder(L"General").WithRelativePositionToParent(RelativePositionToParent::PositionType::FromTopLeft, Point<short>(7, 7)));
+	this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Play infinitely").WithSize(60, 10).InGroup(L"General").WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 11)).WithTabStop().
 		WithID(idPlayInfinitely));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default play length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7)).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default play length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7)).
 		IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idDefaultLength));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default fadeout length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default fadeout length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).
 		IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idDefaultFade));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Skip silence on start (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Skip silence on start (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).
 		IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idSkipSilenceOnStartSec));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Detect silence (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Detect silence (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).
 		IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idDetectSilenceSec));
-	this->configDialog.AddGroupControl(DialogGroupBuilder(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7)));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Volume").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 14)).IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().
+	this->configDialog.AddGroupControl(DialogGroupBuilder(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7)));
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Volume").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 14)).IsLeftJustified());
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idVolume));
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"ReplayGain").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idReplayGain).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"ReplayGain").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idReplayGain).
 		IsDropDownList().WithTabStop());
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Clip Protect").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idClipProtect).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Clip Protect").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idClipProtect).
 		IsDropDownList().WithTabStop());
-	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Sample Rate").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified());
-	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(50, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idSampleRate).
+	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Sample Rate").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified());
+	this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(50, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idSampleRate).
 		IsDropDownList().WithTabStop());
-	this->configDialog.AddGroupControl(DialogGroupBuilder(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7)));
+	this->configDialog.AddGroupControl(DialogGroupBuilder(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7)));
 	this->configDialog.AddLabelControl(DialogLabelBuilder(L"NOTE: This is only used if Advanced Title Formatting is disabled in Winamp.").WithSize(150, 16).InGroup(L"Title Format").
-		WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 11)).IsLeftJustified());
-	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(150, 14).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 4)).IsLeftJustified().
+		WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 11)).IsLeftJustified());
+	this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(150, 14).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 4)).IsLeftJustified().
 		WithAutoHScroll().WithBorder().WithTabStop().WithID(idTitleFormat));
 	this->configDialog.AddLabelControl(DialogLabelBuilder(L"Names between percent symbols (e.g. %game%, %title%) will be replaced with the respective value from the file's tags. Using square brackets around any "
 			L"items will cause them to only be displayed if there was a replacement done (e.g. [%disc%.] will display 01. if disc was in the tags as 01, but will display nothing if disc was not in the tags). Square "
-			L"bracket blocks can be nested.").WithSize(150, 72).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 4)).IsLeftJustified());
+			L"bracket blocks can be nested.").WithSize(150, 72).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 4)).IsLeftJustified());
 
 	this->GenerateSpecificDialogs();
 
-	this->infoDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop());
-	this->infoDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop());
+	this->infoDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop());
+	this->infoDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop());
 	this->infoDialog.AutoSize();
 
 	this->configDialogProperty = this->configDialog;
 	this->configDialogProperty = DialogBuilder().IsChild().IsControlWindow().WithFont(L"MS Shell Dlg", 8);
 	this->configDialogProperty.AutoSize();
 
-	this->configDialog.AddButtonControl(DialogButtonBuilder(L"Reset Defaults").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-50, 7)).WithID(idResetDefaults).
+	this->configDialog.AddButtonControl(DialogButtonBuilder(L"Reset Defaults").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-50, 7)).WithID(idResetDefaults).
 		WithTabStop());
-	this->configDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop());
-	this->configDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop());
+	this->configDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop());
+	this->configDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop());
 	this->configDialog.AutoSize();
 }
 
@@ -233,11 +239,11 @@
 			SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Use Volume Tag"));
 			SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Track"));
 			SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Album"));
-			SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, this->volumeType, 0);
+			SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, static_cast<WPARAM>(this->volumeType), 0);
 			SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Disabled"));
 			SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Track"));
 			SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Album"));
-			SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, this->peakType, 0);
+			SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, static_cast<WPARAM>(this->peakType), 0);
 			for (unsigned x = 0, rates = this->supportedSampleRates.size(); x < rates; ++x)
 			{
 				unsigned rate = this->supportedSampleRates[x];
@@ -336,8 +342,8 @@
 	SetWindowTextW(GetDlgItem(hwndDlg, idSkipSilenceOnStartSec), ConvertFuncs::StringToWString(XSFConfig::initSkipSilenceOnStartSec).c_str());
 	SetWindowTextW(GetDlgItem(hwndDlg, idDetectSilenceSec), ConvertFuncs::StringToWString(XSFConfig::initDetectSilenceSec).c_str());
 	SetWindowTextW(GetDlgItem(hwndDlg, idVolume), ConvertFuncs::TrimDoubleString(std::to_wstring(XSFConfig::initVolume)).c_str());
-	SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, XSFConfig::initVolumeType, 0);
-	SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, XSFConfig::initPeakType, 0);
+	SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, static_cast<WPARAM>(XSFConfig::initVolumeType), 0);
+	SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, static_cast<WPARAM>(XSFConfig::initPeakType), 0);
 	auto found = std::find(this->supportedSampleRates.begin(), this->supportedSampleRates.end(), XSFConfig::initSampleRate);
 	SendMessageW(GetDlgItem(hwndDlg, idSampleRate), CB_SETCURSEL, found - this->supportedSampleRates.begin(), 0);
 	SetWindowTextW(GetDlgItem(hwndDlg, idTitleFormat), ConvertFuncs::StringToWString(XSFConfig::initTitleFormat).c_str());

--- a/src/in_xsf_framework/XSFConfig.h
+++ b/src/in_xsf_framework/XSFConfig.h
@@ -8,11 +8,16 @@
 #pragma once
 
 #include <memory>
-#include "XSFPlayer.h"
+#include <string>
+#include <type_traits>
+#include <vector>
 #include "DialogBuilder.h"
 #include "convert.h"
 #include "windowsh_wrapper.h"
-#include <windowsx.h>
+
+enum class PeakType;
+enum class VolumeType;
+class XSFPlayer;
 
 class XSFConfigIO
 {
@@ -28,11 +33,11 @@
 	}
 
 	// non-enum versions
-	template<typename T> typename std::enable_if_t<!std::is_enum_v<T> &&std::is_arithmetic_v<T>, T> GetValueInternal(const std::string &name, const T &defaultValue) const
+	template<typename T> typename std::enable_if_t<!std::is_enum_v<T> && std::is_arithmetic_v<T>, T> GetValueInternal(const std::string &name, const T &defaultValue) const
 	{
 		return convertTo<T>(this->GetValueString(name, std::to_string(defaultValue)));
 	}
-	template<typename T> typename std::enable_if_t<!std::is_enum_v<T> &&std::is_arithmetic_v<T>> SetValueInternal(const std::string &name, const T &value)
+	template<typename T> typename std::enable_if_t<!std::is_enum_v<T> && std::is_arithmetic_v<T>> SetValueInternal(const std::string &name, const T &value)
 	{
 		this->SetValueString(name, std::to_string(value));
 	}

--- a/src/in_xsf_framework/XSFConfig_Winamp.cpp
+++ b/src/in_xsf_framework/XSFConfig_Winamp.cpp
@@ -6,8 +6,12 @@
  */
 
 #include <filesystem>
+#include <stdexcept>
+#include <string>
+#include <vector>
+#include "windowsh_wrapper.h"
 #include "XSFConfig.h"
-#include "XSFCommon.h"
+#include "convert.h"
 #include "winamp/in2.h"
 #include "winamp/wa_ipc.h"
 

--- a/src/in_xsf_framework/XSFFile.cpp
+++ b/src/in_xsf_framework/XSFFile.cpp
@@ -7,17 +7,22 @@
 
 #include <algorithm>
 #include <filesystem>
-#include <functional>
+#include <fstream>
 #include <stdexcept>
+#include <string>
+#include <vector>
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
+#include "XSFCommon.h"
+#include "XSFFile.h"
+#include "convert.h"
 #if defined(_WIN32) && !defined(_MSC_VER)
 # include "fstream_wfopen.h"
 #endif
 #include "zlib.h"
-#include "XSFFile.h"
-#include "XSFCommon.h"
-#include "convert.h"
-
-static inline void Set32BitsLE(uint32_t input, uint8_t *output)
+
+static inline void Set32BitsLE(std::uint32_t input, std::uint8_t *output)
 {
 	output[0] = input & 0xFF;
 	output[1] = (input >> 8) & 0xFF;
@@ -65,7 +70,7 @@
 	this->ReadXSF(filename, 0, 0, true);
 }
 
-XSFFile::XSFFile(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(filename)
+XSFFile::XSFFile(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(filename)
 {
 	this->ReadXSF(filename, programSizeOffset, programHeaderSize);
 }
@@ -76,13 +81,13 @@
 	this->ReadXSF(filename, 0, 0, true);
 }
 
-XSFFile::XSFFile(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(ConvertFuncs::WStringToString(filename))
+XSFFile::XSFFile(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(ConvertFuncs::WStringToString(filename))
 {
 	this->ReadXSF(filename, programSizeOffset, programHeaderSize);
 }
 #endif
 
-void XSFFile::ReadXSF(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly)
+void XSFFile::ReadXSF(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly)
 {
 	if (!std::filesystem::is_regular_file(filename))
 		throw std::logic_error("File " + filename + " does not exist.");
@@ -97,7 +102,7 @@
 }
 
 #ifdef _WIN32
-void XSFFile::ReadXSF(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly)
+void XSFFile::ReadXSF(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly)
 {
 	if (!std::filesystem::is_regular_file(filename))
 		throw std::logic_error("File " + ConvertFuncs::WStringToString(filename) + " does not exist.");
@@ -116,7 +121,7 @@
 }
 #endif
 
-void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly)
+void XSFFile::ReadXSF(std::ifstream &xSF, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly)
 {
 	xSF.seekg(0, std::ifstream::end);
 	auto filesize = xSF.tellg();
@@ -139,7 +144,7 @@
 	if (filesize < 16)
 		throw std::runtime_error("File is too small.");
 
-	uint32_t reservedSize = Get32BitsLE(xSF), programCompressedSize = Get32BitsLE(xSF);
+	std::uint32_t reservedSize = Get32BitsLE(xSF), programCompressedSize = Get32BitsLE(xSF);
 	this->rawData.resize(reservedSize + programCompressedSize + 16);
 	Set32BitsLE(reservedSize, &this->rawData[4]);
 	Set32BitsLE(programCompressedSize, &this->rawData[8]);
@@ -169,11 +174,11 @@
 			xSF.read(reinterpret_cast<char *>(&this->rawData[reservedSize + 16]), programCompressedSize);
 		else
 		{
-			auto programSectionCompressed = std::vector<uint8_t>(programCompressedSize);
+			auto programSectionCompressed = std::vector<std::uint8_t>(programCompressedSize);
 			xSF.read(reinterpret_cast<char *>(&programSectionCompressed[0]), programCompressedSize);
 			std::copy_n(&programSectionCompressed[0], programCompressedSize, &this->rawData[reservedSize + 16]);
 
-			auto programSectionUncompressed = std::vector<uint8_t>(programHeaderSize);
+			auto programSectionUncompressed = std::vector<std::uint8_t>(programHeaderSize);
 			unsigned long programUncompressedSize = programHeaderSize;
 			uncompress(&programSectionUncompressed[0], &programUncompressedSize, &programSectionCompressed[0], programCompressedSize);
 			programUncompressedSize = Get32BitsLE(&programSectionUncompressed[programSizeOffset]) + programHeaderSize;
@@ -231,7 +236,7 @@
 	this->hasFile = true;
 }
 
-bool XSFFile::IsValidType(uint8_t type) const
+bool XSFFile::IsValidType(std::uint8_t type) const
 {
 	return this->xSFType == type;
 }
@@ -250,22 +255,22 @@
 	return this->hasFile;
 }
 
-std::vector<uint8_t> &XSFFile::GetReservedSection()
+std::vector<std::uint8_t> &XSFFile::GetReservedSection()
 {
 	return this->reservedSection;
 }
 
-std::vector<uint8_t> XSFFile::GetReservedSection() const
+std::vector<std::uint8_t> XSFFile::GetReservedSection() const
 {
 	return this->reservedSection;
 }
 
-std::vector<uint8_t> &XSFFile::GetProgramSection()
+std::vector<std::uint8_t> &XSFFile::GetProgramSection()
 {
 	return this->programSection;
 }
 
-std::vector<uint8_t> XSFFile::GetProgramSection() const
+std::vector<std::uint8_t> XSFFile::GetProgramSection() const
 {
 	return this->programSection;
 }
@@ -322,19 +327,19 @@
 
 double XSFFile::GetVolume(VolumeType preferredVolumeType, PeakType preferredPeakType) const
 {
-	if (preferredVolumeType == VOLUMETYPE_NONE)
+	if (preferredVolumeType == VolumeType::None)
 		return 1.0;
 	std::string replaygain_album_gain = this->GetTagValue("replaygain_album_gain"), replaygain_album_peak = this->GetTagValue("replaygain_album_peak");
 	std::string replaygain_track_gain = this->GetTagValue("replaygain_track_gain"), replaygain_track_peak = this->GetTagValue("replaygain_track_peak");
 	std::string volume = this->GetTagValue("volume");
 	double gain = 0.0;
 	bool hadReplayGain = false;
-	if (preferredVolumeType == VOLUMETYPE_REPLAYGAIN_ALBUM && !replaygain_album_gain.empty())
+	if (preferredVolumeType == VolumeType::ReplayGainAlbum && !replaygain_album_gain.empty())
 	{
 		gain = convertTo<double>(replaygain_album_gain);
 		hadReplayGain = true;
 	}
-	if (!hadReplayGain && preferredVolumeType != VOLUMETYPE_VOLUME && !replaygain_track_gain.empty())
+	if (!hadReplayGain && preferredVolumeType != VolumeType::Volume && !replaygain_track_gain.empty())
 	{
 		gain = convertTo<double>(replaygain_track_gain);
 		hadReplayGain = true;
@@ -342,9 +347,9 @@
 	if (hadReplayGain)
 	{
 		double vol = std::pow(10.0, gain / 20.0), peak = 1.0;
-		if (preferredPeakType == PEAKTYPE_REPLAYGAIN_ALBUM && !replaygain_album_peak.empty())
+		if (preferredPeakType == PeakType::ReplayGainAlbum && !replaygain_album_peak.empty())
 			peak = convertTo<double>(replaygain_album_peak);
-		else if (preferredPeakType != PEAKTYPE_NONE && !replaygain_track_peak.empty())
+		else if (preferredPeakType != PeakType::None && !replaygain_track_peak.empty())
 			peak = convertTo<double>(replaygain_track_peak);
 		return !fEqual(peak, 1.0) ? std::min(vol, 1.0 / peak) : vol;
 	}
@@ -354,12 +359,12 @@
 std::string XSFFile::FormattedTitleOptionalBlock(const std::string &block, bool &hadReplacement, unsigned level) const
 {
 	std::string formattedBlock;
-	for (size_t x = 0, len = block.length(); x < len; ++x)
+	for (std::size_t x = 0, len = block.length(); x < len; ++x)
 	{
 		char c = block[x];
 		if (c == '%')
 		{
-			size_t origX = x;
+			std::size_t origX = x;
 			for (++x; x < len; ++x)
 				if (block[x] == '%')
 					break;
@@ -377,7 +382,7 @@
 		}
 		if (c == '[' && level + 1 < 10)
 		{
-			size_t origX = x;
+			std::size_t origX = x;
 			unsigned nests = 0;
 			for (++x; x < len; ++x)
 			{
@@ -408,12 +413,12 @@
 std::string XSFFile::GetFormattedTitle(const std::string &format) const
 {
 	std::string formattedTitle;
-	for (size_t x = 0, len = format.length(); x < len; ++x)
+	for (std::size_t x = 0, len = format.length(); x < len; ++x)
 	{
 		char c = format[x];
 		if (c == '%')
 		{
-			size_t origX = x;
+			std::size_t origX = x;
 			for (++x; x < len; ++x)
 				if (format[x] == '%')
 					break;
@@ -429,7 +434,7 @@
 		}
 		else if (c == '[')
 		{
-			size_t origX = x;
+			std::size_t origX = x;
 			unsigned nests = 0;
 			for (++x; x < len; ++x)
 			{

--- a/src/in_xsf_framework/XSFFile.h
+++ b/src/in_xsf_framework/XSFFile.h
@@ -7,54 +7,57 @@
 
 #pragma once
 
+#include <fstream>
+#include <string>
+#include <vector>
 #include <cstdint>
 #include "convert.h"
 #include "TagList.h"
 
-enum VolumeType
+enum class VolumeType
 {
-	VOLUMETYPE_NONE,
-	VOLUMETYPE_VOLUME,
-	VOLUMETYPE_REPLAYGAIN_TRACK,
-	VOLUMETYPE_REPLAYGAIN_ALBUM
+	None,
+	Volume,
+	ReplayGainTrack,
+	ReplayGainAlbum
 };
 
-enum PeakType
+enum class PeakType
 {
-	PEAKTYPE_NONE,
-	PEAKTYPE_REPLAYGAIN_TRACK,
-	PEAKTYPE_REPLAYGAIN_ALBUM
+	None,
+	ReplayGainTrack,
+	ReplayGainAlbum
 };
 
 class XSFFile
 {
 protected:
-	uint8_t xSFType;
+	std::uint8_t xSFType;
 	bool hasFile;
-	std::vector<uint8_t> rawData, reservedSection, programSection;
+	std::vector<std::uint8_t> rawData, reservedSection, programSection;
 	TagList tags;
 	std::string fileName;
-	void ReadXSF(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false);
+	void ReadXSF(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false);
 #ifdef _WIN32
-	void ReadXSF(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false);
+	void ReadXSF(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false);
 #endif
-	void ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false);
+	void ReadXSF(std::ifstream &xSF, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false);
 	std::string FormattedTitleOptionalBlock(const std::string &block, bool &hadReplacement, unsigned level) const;
 public:
 	XSFFile();
 	XSFFile(const std::string &filename);
-	XSFFile(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize);
+	XSFFile(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize);
 #ifdef _WIN32
 	XSFFile(const std::wstring &filename);
-	XSFFile(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize);
+	XSFFile(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize);
 #endif
-	bool IsValidType(uint8_t type) const;
+	bool IsValidType(std::uint8_t type) const;
 	void Clear();
 	bool HasFile() const;
-	std::vector<uint8_t> &GetReservedSection();
-	std::vector<uint8_t> GetReservedSection() const;
-	std::vector<uint8_t> &GetProgramSection();
-	std::vector<uint8_t> GetProgramSection() const;
+	std::vector<std::uint8_t> &GetReservedSection();
+	std::vector<std::uint8_t> GetReservedSection() const;
+	std::vector<std::uint8_t> &GetProgramSection();
+	std::vector<std::uint8_t> GetProgramSection() const;
 	const TagList &GetAllTags() const;
 	void SetAllTags(const TagList &newTags);
 	void SetTag(const std::string &name, const std::string &value);

--- a/src/in_xsf_framework/XSFPlayer.cpp
+++ b/src/in_xsf_framework/XSFPlayer.cpp
@@ -5,10 +5,13 @@
  * Partially based on the vio*sf framework
  */
 
-#include <cstring>
+#include <algorithm>
+#include <limits>
+#include <vector>
+#include <cstdint>
+#include "XSFCommon.h"
+#include "XSFConfig.h"
 #include "XSFPlayer.h"
-#include "XSFConfig.h"
-#include "XSFCommon.h"
 
 extern XSFConfig *xSFConfig;
 
@@ -50,26 +53,26 @@
 	return *this;
 }
 
-bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten)
+bool XSFPlayer::FillBuffer(std::vector<std::uint8_t> &buf, unsigned &samplesWritten)
 {
 	bool endFlag = false;
 	unsigned detectSilence = xSFConfig->GetDetectSilenceSec();
 	unsigned pos = 0, bufsize = buf.size() >> 2;
-	auto trueBuffer = std::vector<uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2));
-	auto longBuffer = std::vector<uint8_t>(bufsize << 3);
-	auto bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]);
+	auto trueBuffer = std::vector<std::uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2));
+	auto longBuffer = std::vector<std::uint8_t>(bufsize << 3);
+	auto bufLong = reinterpret_cast<std::int32_t *>(&longBuffer[0]);
 	while (pos < bufsize)
 	{
 		unsigned remain = bufsize - pos, offset = pos;
 		this->GenerateSamples(trueBuffer, pos << (this->uses32BitSamplesClampedTo16Bit ? 2 : 1), remain);
 		if (this->uses32BitSamplesClampedTo16Bit)
 		{
-			auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
+			auto trueBufLong = reinterpret_cast<std::int32_t *>(&trueBuffer[0]);
 			std::copy_n(&trueBufLong[0], bufsize << 1, &bufLong[0]);
 		}
 		else
 		{
-			auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+			auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]);
 			std::copy_n(&trueBufShort[0], bufsize << 1, &bufLong[0]);
 		}
 		if (detectSilence || skipSilenceOnStartSec)
@@ -77,7 +80,7 @@
 			unsigned skipOffset = 0;
 			for (unsigned ofs = 0; ofs < remain; ++ofs)
 			{
-				uint32_t sampleL = bufLong[2 * (offset + ofs)], sampleR = bufLong[2 * (offset + ofs) + 1];
+				std::uint32_t sampleL = bufLong[2 * (offset + ofs)], sampleR = bufLong[2 * (offset + ofs) + 1];
 				bool silence = (sampleL + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleL <= CHECK_SILENCE_LEVEL * 2 &&
 					(sampleR + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleR <= CHECK_SILENCE_LEVEL * 2;
 
@@ -114,7 +117,7 @@
 			{
 				if (skipOffset)
 				{
-					auto tmpBuf = std::vector<int32_t>((bufsize - skipOffset) << 1);
+					auto tmpBuf = std::vector<std::int32_t>((bufsize - skipOffset) << 1);
 					std::copy(&bufLong[(offset + skipOffset) << 1], &bufLong[bufsize << 1], &tmpBuf[0]);
 					std::copy_n(&tmpBuf[0], (bufsize - skipOffset) << 1, &bufLong[offset << 1]);
 					pos += skipOffset;
@@ -129,12 +132,12 @@
 		{
 			if (this->uses32BitSamplesClampedTo16Bit)
 			{
-				auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]);
+				auto trueBufLong = reinterpret_cast<std::int32_t *>(&trueBuffer[0]);
 				std::copy_n(&bufLong[0], bufsize << 1, &trueBufLong[0]);
 			}
 			else
 			{
-				auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+				auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]);
 				std::copy_n(&bufLong[0], bufsize << 1, &trueBufShort[0]);
 			}
 		}
@@ -164,29 +167,29 @@
 			double s1 = bufLong[2 * ofs] * scale, s2 = bufLong[2 * ofs + 1] * scale;
 			if (!this->uses32BitSamplesClampedTo16Bit)
 			{
-				clamp(s1, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max());
-				clamp(s2, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max());
-			}
-			bufLong[2 * ofs] = static_cast<int32_t>(s1);
-			bufLong[2 * ofs + 1] = static_cast<int32_t>(s2);
+				clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+				clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+			}
+			bufLong[2 * ofs] = static_cast<std::int32_t>(s1);
+			bufLong[2 * ofs + 1] = static_cast<std::int32_t>(s2);
 		}
 	}
 
 	if (this->uses32BitSamplesClampedTo16Bit)
 	{
-		auto bufShort = reinterpret_cast<int16_t *>(&buf[0]);
+		auto bufShort = reinterpret_cast<std::int16_t *>(&buf[0]);
 		for (unsigned ofs = 0; ofs < bufsize; ++ofs)
 		{
-			int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1];
-			clamp(s1, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max());
-			clamp(s2, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max());
-			bufShort[2 * ofs] = static_cast<int16_t>(s1);
-			bufShort[2 * ofs + 1] = static_cast<int16_t>(s2);
+			std::int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1];
+			clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+			clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+			bufShort[2 * ofs] = static_cast<std::int16_t>(s1);
+			bufShort[2 * ofs + 1] = static_cast<std::int16_t>(s2);
 		}
 	}
 	else
 	{
-		auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]);
+		auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]);
 		std::copy_n(&bufLong[0], bufsize << 1, &trueBufShort[0]);
 		std::copy(&trueBuffer[0], &trueBuffer[bufsize << 2], &buf[0]);
 	}
@@ -194,12 +197,12 @@
 	/* Fading */
 	if (!xSFConfig->GetPlayInfinitely() && this->fadeSample && this->currentSample + bufsize >= this->lengthSample)
 	{
-		auto bufShort = reinterpret_cast<int16_t *>(&buf[0]);
+		auto bufShort = reinterpret_cast<std::int16_t *>(&buf[0]);
 		for (unsigned ofs = 0; ofs < bufsize; ++ofs)
 		{
 			if (this->currentSample + ofs >= this->lengthSample && this->currentSample + ofs < this->lengthSample + this->fadeSample)
 			{
-				int scale = static_cast<uint64_t>(this->lengthSample + this->fadeSample - (this->currentSample + ofs)) * 0x10000 / this->fadeSample;
+				int scale = static_cast<std::uint64_t>(this->lengthSample + this->fadeSample - (this->currentSample + ofs)) * 0x10000 / this->fadeSample;
 				bufShort[2 * ofs] = (bufShort[2 * ofs] * scale) >> 16;
 				bufShort[2 * ofs + 1] = (bufShort[2 * ofs + 1] * scale) >> 16;
 			}
@@ -217,8 +220,8 @@
 {
 	this->lengthInMS = this->xSF->GetLengthMS(xSFConfig->GetDefaultLength());
 	this->fadeInMS = this->xSF->GetFadeMS(xSFConfig->GetDefaultFade());
-	this->lengthSample = static_cast<uint64_t>(this->lengthInMS) * this->sampleRate / 1000;
-	this->fadeSample = static_cast<uint64_t>(this->fadeInMS) * this->sampleRate / 1000;
+	this->lengthSample = static_cast<std::uint64_t>(this->lengthInMS) * this->sampleRate / 1000;
+	this->fadeSample = static_cast<std::uint64_t>(this->fadeInMS) * this->sampleRate / 1000;
 	this->volume = this->xSF->GetVolume(xSFConfig->GetVolumeType(), xSFConfig->GetPeakType());
 	return true;
 }
@@ -233,9 +236,9 @@
 #ifdef WINAMP_PLUGIN
 static inline DWORD TicksDiff(DWORD prev, DWORD cur) { return cur >= prev ? cur - prev : 0xFFFFFFFF - prev + cur; }
 
-int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod)
-{
-	unsigned bufsize = buf.size() >> 2, seekSample = static_cast<uint64_t>(seekPosition) * this->sampleRate / 1000;
+int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector<std::uint8_t> &buf, Out_Module *outMod)
+{
+	unsigned bufsize = buf.size() >> 2, seekSample = static_cast<std::uint64_t>(seekPosition) * this->sampleRate / 1000;
 	DWORD prevTick = outMod ? GetTickCount() : 0;
 	if (seekSample < this->currentSample)
 	{
@@ -253,7 +256,7 @@
 			if (TicksDiff(prevTick, curTick) >= 500)
 			{
 				prevTick = curTick;
-				unsigned cur = static_cast<uint64_t>(this->currentSample) * 1000 / this->sampleRate;
+				unsigned cur = static_cast<std::uint64_t>(this->currentSample) * 1000 / this->sampleRate;
 				outMod->Flush(cur);
 			}
 		}

--- a/src/in_xsf_framework/XSFPlayer.h
+++ b/src/in_xsf_framework/XSFPlayer.h
@@ -8,8 +8,10 @@
 #pragma once
 
 #include <memory>
+#include <string>
+#include <vector>
+#include <cstdint>
 #include "XSFFile.h"
-
 #ifdef WINAMP_PLUGIN
 # include "windowsh_wrapper.h"
 # include "winamp/out.h"
@@ -19,12 +21,12 @@
 class XSFPlayer
 {
 protected:
-	static const uint32_t CHECK_SILENCE_BIAS = 0x8000000;
-	static const uint32_t CHECK_SILENCE_LEVEL = 7;
+	static const std::uint32_t CHECK_SILENCE_BIAS = 0x8000000;
+	static const std::uint32_t CHECK_SILENCE_LEVEL = 7;
 
 	std::unique_ptr<XSFFile> xSF;
 	unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample;
-	uint32_t prevSampleL, prevSampleR;
+	std::uint32_t prevSampleL, prevSampleR;
 	int lengthInMS, fadeInMS;
 	double volume;
 	bool ignoreVolume, uses32BitSamplesClampedTo16Bit;
@@ -49,11 +51,11 @@
 	void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
 	void IgnoreVolume() { this->ignoreVolume = true; }
 	virtual bool Load();
-	bool FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten);
-	virtual void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) = 0;
+	bool FillBuffer(std::vector<std::uint8_t> &buf, unsigned &samplesWritten);
+	virtual void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) = 0;
 	void SeekTop();
 #ifdef WINAMP_PLUGIN
-	int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod);
+	int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<std::uint8_t> &buf, Out_Module *outMod);
 #endif
 	virtual void Terminate() = 0;
 };

--- a/src/in_xsf_framework/convert.h
+++ b/src/in_xsf_framework/convert.h
@@ -5,13 +5,12 @@
 
 #pragma once
 
+#include <locale>
 #include <string>
-#include <sstream>
-#include <locale>
+#include <type_traits>
 #include <vector>
-#include <memory>
-#include <type_traits>
 #include <cmath>
+#include <cstddef>
 #include "windowsh_wrapper.h"
 
 /*
@@ -62,10 +61,10 @@
 	template<typename T> static bool IsDigitsOnly(const std::basic_string<T> &input, const std::locale &loc = std::locale::classic())
 	{
 		auto inputChars = std::vector<T>(input.begin(), input.end());
-		size_t length = inputChars.size();
+		std::size_t length = inputChars.size();
 		auto masks = std::vector<typename std::ctype<T>::mask>(length);
 		std::use_facet<std::ctype<T>>(loc).is(&inputChars[0], &inputChars[length], &masks[0]);
-		for (size_t x = 0; x < length; ++x)
+		for (std::size_t x = 0; x < length; ++x)
 			if (inputChars[x] != '.' && !(masks[x] & std::ctype<T>::digit))
 				return false;
 		return true;
@@ -77,10 +76,10 @@
 		unsigned long hours = 0, minutes = 0;
 		double seconds = 0.0;
 		std::string hoursStr, minutesStr, secondsStr;
-		size_t firstcolon = time.find(':');
+		std::size_t firstcolon = time.find(':');
 		if (firstcolon != std::string::npos)
 		{
-			size_t secondcolon = time.substr(firstcolon + 1).find(':');
+			std::size_t secondcolon = time.substr(firstcolon + 1).find(':');
 			if (secondcolon != std::string::npos)
 			{
 				secondcolon = firstcolon + secondcolon + 1;
@@ -112,7 +111,7 @@
 		{
 			if (!ConvertFuncs::IsDigitsOnly(secondsStr))
 				return 0;
-			size_t comma = secondsStr.find(',');
+			std::size_t comma = secondsStr.find(',');
 			if (comma != std::string::npos)
 				secondsStr[comma] = '.';
 			seconds = convertTo<double>(secondsStr);

--- a/src/in_xsf_framework/eqstr.h
+++ b/src/in_xsf_framework/eqstr.h
@@ -8,11 +8,10 @@
 
 #pragma once
 
-#include <functional>
+#include <algorithm>
+#include <limits>
 #include <locale>
 #include <string>
-#include <algorithm>
-#include <climits>
 
 struct eq_str
 {
@@ -20,16 +19,16 @@
 	{
 		const char *tab;
 		eq_char(const char *t) : tab(t) { }
-		bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] == this->tab[y - CHAR_MIN]; }
+		bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] == this->tab[y - std::numeric_limits<char>::min()]; }
 	};
 
-	char tab[CHAR_MAX - CHAR_MIN + 1];
+	char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1];
 
 	eq_str(const std::locale &L = std::locale::classic())
 	{
-		for (int i = CHAR_MIN; i <= CHAR_MAX; ++i)
-			this->tab[i - CHAR_MIN] = static_cast<char>(i);
-		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
+		for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i)
+			this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i);
+		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1));
 	}
 
 	bool operator()(const std::string &x, const std::string &y) const

--- a/src/in_xsf_framework/in_xsf.cpp
+++ b/src/in_xsf_framework/in_xsf.cpp
@@ -5,10 +5,20 @@
  * Partially based on the vio*sf framework
  */
 
+#include <algorithm>
+#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
+#include <vector>
+#include <cstddef>
+#include <cstdint>
+#include "windowsh_wrapper.h"
+#include "XSFCommon.h"
+#include "XSFConfig.h"
+#include "XSFFile.h"
 #include "XSFPlayer.h"
-#include "XSFConfig.h"
-#include "XSFCommon.h"
-#include "windowsh_wrapper.h"
+#include "convert.h"
 #include "winamp/in2.h"
 #include "winamp/wa_ipc.h"
 
@@ -35,7 +45,7 @@
 		{
 			decode_pos_ms = seek_needed - (seek_needed % 1000);
 			seek_needed = -1;
-			auto dummyBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8));
+			auto dummyBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8));
 			xSFPlayer->Seek(static_cast<unsigned>(decode_pos_ms), nullptr, dummyBuffer, inMod.outMod);
 		}
 
@@ -51,7 +61,7 @@
 		}
 		else if (static_cast<unsigned>(inMod.outMod->CanWrite()) >= ((576 * NumChannels * (BitsPerSample / 8)) << (inMod.dsp_isactive() ? 1 : 0)))
 		{
-			auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8));
+			auto sampleBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8));
 			unsigned samplesWritten = 0;
 			done = xSFPlayer->FillBuffer(sampleBuffer, samplesWritten);
 			if (samplesWritten)
@@ -305,7 +315,7 @@
 
 static eq_str eqstr;
 
-template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, const char *data, T *dest, size_t destlen)
+template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, const char *data, T *dest, std::size_t destlen)
 {
 	if (eqstr(data, "type"))
 	{
@@ -343,7 +353,7 @@
 	}
 }
 
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, size_t destlen)
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, std::size_t destlen)
 {
 	try
 	{
@@ -356,7 +366,7 @@
 	}
 }
 
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, size_t destlen)
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, std::size_t destlen)
 {
 	try
 	{
@@ -418,7 +428,7 @@
 	return 0;
 }
 
-intptr_t wrapperWinampGetExtendedRead_open(std::unique_ptr<XSFPlayer> tmpxSFPlayer, int *size, int *bps, int *nch, int *srate)
+std::intptr_t wrapperWinampGetExtendedRead_open(std::unique_ptr<XSFPlayer> &&tmpxSFPlayer, int *size, int *bps, int *nch, int *srate)
 {
 	xSFConfig->CopyConfigToMemory(tmpxSFPlayer.get(), true);
 	if (!tmpxSFPlayer->Load())
@@ -433,10 +443,10 @@
 		*nch = NumChannels;
 	if (srate)
 		*srate = tmpxSFPlayer->GetSampleRate();
-	return reinterpret_cast<intptr_t>(tmpxSFPlayer.release());
-}
-
-extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate)
+	return reinterpret_cast<std::intptr_t>(tmpxSFPlayer.release());
+}
+
+extern "C" __declspec(dllexport) std::intptr_t winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate)
 {
 	try
 	{
@@ -449,7 +459,7 @@
 	}
 }
 
-extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate)
+extern "C" __declspec(dllexport) std::intptr_t winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate)
 {
 	try
 	{
@@ -464,14 +474,14 @@
 
 static int extendedSeekNeeded = -1;
 
-extern "C" __declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t handle, char *dest, size_t len, int *killswitch)
+extern "C" __declspec(dllexport) std::size_t winampGetExtendedRead_getData(std::intptr_t handle, char *dest, std::size_t len, int *killswitch)
 {
 	XSFPlayer *tmpxSFPlayer = reinterpret_cast<XSFPlayer *>(handle);
 	if (!tmpxSFPlayer)
 		return 0;
 	if (extendedSeekNeeded != -1)
 	{
-		auto dummyBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8));
+		auto dummyBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8));
 		if (tmpxSFPlayer->Seek(static_cast<unsigned>(extendedSeekNeeded), killswitch, dummyBuffer, nullptr))
 			return 0;
 		extendedSeekNeeded = -1;
@@ -480,7 +490,7 @@
 	bool done = false;
 	while (copied + (576 * NumChannels * (BitsPerSample / 8)) < len && !done)
 	{
-		auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8));
+		auto sampleBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8));
 		unsigned samplesWritten = 0;
 		done = tmpxSFPlayer->FillBuffer(sampleBuffer, samplesWritten);
 		std::copy_n(&sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8), &dest[copied]);
@@ -491,13 +501,13 @@
 	return copied;
 }
 
-extern "C" __declspec(dllexport) int winampGetExtendedRead_setTime(intptr_t, int millisecs)
+extern "C" __declspec(dllexport) int winampGetExtendedRead_setTime(std::intptr_t, int millisecs)
 {
 	extendedSeekNeeded = millisecs;
 	return 1;
 }
 
-extern "C" __declspec(dllexport) void winampGetExtendedRead_close(intptr_t handle)
+extern "C" __declspec(dllexport) void winampGetExtendedRead_close(std::intptr_t handle)
 {
 	XSFPlayer *tmpxSFPlayer = reinterpret_cast<XSFPlayer *>(handle);
 	if (tmpxSFPlayer)

--- a/src/in_xsf_framework/ltstr.h
+++ b/src/in_xsf_framework/ltstr.h
@@ -8,11 +8,10 @@
 
 #pragma once
 
-#include <functional>
+#include <algorithm>
+#include <limits>
 #include <locale>
 #include <string>
-#include <algorithm>
-#include <climits>
 
 struct lt_str
 {
@@ -20,16 +19,16 @@
 	{
 		const char *tab;
 		lt_char(const char *t) : tab(t) { }
-		bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] < this->tab[y - CHAR_MIN]; }
+		bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] < this->tab[y - std::numeric_limits<char>::min()]; }
 	};
 
-	char tab[CHAR_MAX - CHAR_MIN + 1];
+	char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1];
 
 	lt_str(const std::locale &L = std::locale::classic())
 	{
-		for (int i = CHAR_MIN; i <= CHAR_MAX; ++i)
-			this->tab[i - CHAR_MIN] = static_cast<char>(i);
-		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1));
+		for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i)
+			this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i);
+		std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1));
 	}
 
 	bool operator()(const std::string &x, const std::string &y) const